Android - Format Timestamp in ListView with Cursor Adapter

前端 未结 3 530
迷失自我
迷失自我 2021-01-05 04:57

I am using a SimpleCursorAdapter to populate an Android ListView, and was wondering how I should go about getting all of the timestamps I get from a database, each in \"DATE

3条回答
  •  时光说笑
    2021-01-05 05:49

    Store Unix epoch dates as INTEGER type in SQLite database. Then in Java, initialize them with new Date(value) (or value*1000, I'm not sure) and use SimpleDateFormat to format dates in list adapter.

    I think that's the most convenient way for the limited information you've provided.

提交回复
热议问题