Click here to Skip to main content
16,004,778 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello guys I have a query regarding the storing the time in database with correct format.

In my app i create a 2 buttons START TIME & END TIME open the time picker and select the time and after show it on form with textview and as well as it store it in database also.In database i have a TIMES table which contain 3 fields id, starttime and closetime.

Now my problem is that the time which i select from time picker is different it shows on form is also different and in database it also shows the different entry.

Please help me to solve this problem.

Thanks in advance
Posted
Comments
Devang Vaja 5-Mar-13 1:07am    
hello varsha ji which db r u using?
mysql or sql server?
Varsha Bhatia 5-Mar-13 1:16am    
sir sqlite database m using..sir minor problem which i solve but still i have a prob which is start time and end time both are same in database..
Devang Vaja 5-Mar-13 1:20am    
r u using webservice to insert?
Varsha Bhatia 5-Mar-13 1:22am    
no sir i paste a code here

public long updateTimeRecord(long id, Calendar calendar) {
ContentValues values = new ContentValues();

// Here is where we apply the Data DateFormat:
values.put(COL_START_TIME, TimeDataFormate.formatDateAsLong(calendar));
values.put(COL_CLOSE_TIME, TimeDataFormate.formatDateAsLong(calendar));

return mDb.update(TABLE_TIME, values, COL_ID1 + "=" + id, null);
}
Varsha Bhatia 5-Mar-13 1:24am    
// This is only used for TIME table which define the start and close time
public Cursor fetchTimeList() {
Cursor cursor = mDb.query(TABLE_TIME, new String[] { COL_ID1,
COL_START_TIME, COL_CLOSE_TIME }, null, null, null, null, null);
if (cursor != null) {
cursor.moveToFirst();
}
return cursor;
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900