How do I get the Timestamp value from database column via a cursor and store it in a Timestamp variable in android sdk?
I’m using the java.sql.Timestamp and the value in the sqlite database is of type TIMESTAMP.
I have created an class having all the fields as the database column names and wish to create a new object after reading a record from the database.
How do I get the Timestamp value from database column via a cursor and
Share
You have to use the Cursor methods to get the value as a string and then use the Timestamp class’s static valueOf method to convert it back to a proper Timestamp:
I use this all over the place and it works like a charm. For example, while iterating over the result set, you can set the Timestamp fields of your object.
I hope that’s what you’re looking for.