In order to let the Sqlite understand the date time value you inserted directly w/o explicit conversion I found two options;
1. You need to find a function that returns the number of days since noon in Greenwich on November 24, 4714 B.C. to now in Java for Julian time which Sqlite's default.
2. Convert the input date time in ISO8601 format which Sqlite understands as a date time value.
I have chosen the second alternative;
/**
* Get at the moment within ISO8601 format.
* @return
* Date and time in ISO8601 format.
*/
private String getNow()
{
Calendar c = Calendar.getInstance();
SimpleDateFormat sdf =
new SimpleDateFormat(
getResources().getString(R.string.DATE_FORMAT_ISO8601));
return sdf.format(c.getTime());
}
In strings.xml specify the ISO standard;
Comments
Unknown · 8 October 2009
Thanks, just what I needed!
Anonymous · 20 April 2011
Many thanks i were searching for this as well. as using the "SETDATE" just saves a integer and does not work as expected, but using this method works.