0

I'm trying to modify an existing notepad example from the Android Developer site. I have a database with an existing column named CREATED_DATE(of the note) but the data for that column is presented as System.currentTimeMillis(). This is all good and probably in line with conventions since it's created by the developers.

But my problem is that I want to present the date in a ListView using the format "30 sep". My problem, how do I convert the data to that format before presenting it in the ListView? Right now I'm using this kind of adapter:

SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.noteslist_item, cursor,
        new String[] { Notes.TITLE, Notes.CREATED_DATE }, new int[] { R.id.note_title, R.id.note_date });
setListAdapter(adapter);

Now, I've figured out how to convert currentTimeMillis() to today's date but how can I convert the data coming from the cursor before I toss it into the adapter?

user
  • 86,916
  • 18
  • 197
  • 190
Dennis
  • 1

2 Answers2

0

If I understand your question correctly, take a look at the Date and SimpleDateFormat classes in order to convert your ms long into a String representation.

(There are lots of examples on stackoverflow on how to actually use those classes)

James
  • 3,729
  • 3
  • 20
  • 16
0

You have to change the ViewBinder. Have a look at this Changing values from Cursor using SimpleCursorAdapter It helped me..

Community
  • 1
  • 1
Norfeldt
  • 8,272
  • 23
  • 96
  • 152