I am trying to format a list of dates(on user entry) and display in chronological order in a list view.
I am currently able to display them in list view and enter them as an un-formatted date.
I am wanting to format them as follows: DD/MM/YYYY
This is the code i have for retrieving the date and the ID from the db and displaying it in the listView
lessonNotesList class:
final int VALUE = extras.getInt("studentId");
mydb = new DBHelper(this);
final ArrayList id_list = mydb.getAllLessonIds(VALUE);
ArrayList array_list = mydb.getAllLessonNotes(VALUE);
//Collections.sort(array_list, Collections.reverseOrder());
//Collections.sort(array_list);
ArrayAdapter arrayAdapter = new ArrayAdapter(this,R.layout.list_layout, array_list);
//Adding the contacts to the list view.
lessonNote = (ListView)findViewById(R.id.listViewLesson);
lessonNote.setAdapter(arrayAdapter);
//Setting an onClickListener to process the user's actions
lessonNote.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
//Prepare the data from the ListView item to be passed to new activity
int id_To_Search =Integer.valueOf((String)id_list.get(arg2));
//Log.d("Id is ^&*: ", String.valueOf(id_To_Search));
//Create a new intent to open the DisplayContact activity
Intent lessonList = new Intent(getApplicationContext(), com.example.ltss.dyslexia.app.LessonNotes.class);
lessonList.putExtra("studentId", VALUE);
lessonList.putExtra("lessonId", id_To_Search);
lessonList.putExtras(lessonList);
startActivity(lessonList);
}
});
LessonNotesPage class (displays the lesson note information/allows for user entry)
String dateLesson = rs.getString(rs.getColumnIndex(DBHelper.DATE));
if (!rs.isClosed()) {
rs.close();
}
lessonDate.setText(dateLesson);
lessonDate.setFocusable(true);
lessonDate.setClickable(true);// allows user entry
How do I get the date formatted on user entry and how can i get it sorted in chronological order?