0

Im using SQLite and trying to get my date into a blackberry datetime field.

in the DB its stored as string in format:

yyyy-MM-dd HH:mm

e.g. : 2012-02-01 15:45

But the field wants it as a Long.

date - The initial date value for this field. This is the number of milliseconds since midnight on January 1, 1970. To create an empty date field, set this parameter to Long.MIN_VALUE. This method will then remove the date value from this field, setting it to null.

And then convert it back again.

4

1 回答 1

4

检查以下代码:

// conversion - string to long
long dateLong = HttpDateParser.parse("2012-04-17 16:09");

// conversion - long to string
Date dateObject = new Date(dateLong);        
String dateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm")).format(dateObject);
于 2012-04-17T10:11:05.793 回答