At the db side, checkInTime and checkOutTime are of type TIMESTAMP
In my java code also, checkInTime and checkOutTime are of type java.sql.Timestamp
For inserting a record into db, i am using this piece of code:
1. ContentValues contentValues=new ContentValues();
2. contentValues.put(USER_ID, userId);
3. contentValues.put(ROOM_ID, roomId);
4. contentValues.put(CHECK_IN, checkInTime);
5. contentValues.put(CHECK_OUT, checkOutTime);
6. return database.insert(MRM_BOOKING_DETAILS_TABLE, null, contentValues);
But i am getting compilation errors at line 4 and 5 since they are not expecting something of type java.sql.Timestamp
I can’t see any put method of ContentValues which will accept type java.sql.Timestamp in its second parameter. Please suggest how to pass the java.sql.Timestamp in such a case so that i can remove the compilation errors as well.
Thanks,
I would suggest you to use
DATETIMEinstead ofTIMESTAMP. Its more general when handling dates and times.Moreover, you can use SimpleDateFormat to parse DATETIME values when inserting or reading from database.
Updated:
Try doing it as below: