开发者

Adding Modified Date to ListView in NotePad Sample Code

开发者 https://www.devze.com 2023-02-01 01:16 出处:网络
I am trying to modify the NotePad sample code from the Android developer resources. The date is stored in a SQLi开发者_如何学运维te database as a Long and retrieved using the SimpleCursorAdapter.

I am trying to modify the NotePad sample code from the Android developer resources. The date is stored in a SQLi开发者_如何学运维te database as a Long and retrieved using the SimpleCursorAdapter.

http://developer.android.com/resources/samples/NotePad/index.html

When I call the MODIFIED_DATE with the Notes ListView, it returns as an milliseconds/Unix format. (Below) Ideally I would like to show "12-15-2010".

Any suggestions would be appreciated. I have tried a bunch of things (e.g. creating a new column in the database) and ended up with a lot of Force Closes.

Thank you.


To convert a date/time represented as milliseconds to a human readable one, you need to look at the android.text.format.DateFormat class and, in particular, this method...

CharSequence format(CharSequence inFormat, long inTimeInMillis)

The Class Overview gives examples of formatting characters.

0

精彩评论

暂无评论...
验证码 换一张
取 消