I have a GridView that I populate from my SQLite Database through SimpleCursorAdapter as follows
public void Paygrid() {
final Account Acc = (Account) getIntent().getSerializableExtra("FromDetails");
dbHelper = new DatabaseHelper(this);
String Payment = String.valueOf(Acc._id);
Cursor a = dbHelper.FilterPayments(Payment);
startManagingCursor(a);
String[] from = new String[]{DatabaseHelper.colPayBal, DatabaseHelper.colInterest, DatabaseHelper.colPayDue, DatabaseHelper.colDateDue, DatabaseHelper.colPayDate};
int[] to = new int[]{R.id.Amount, R.id.Interest, R.id.Total, R.id.DateDue, R.id.Paid};
SimpleCursorAdapter saa = new SimpleCursorAdapter(this, R.layout.paygrid, a, from, to);
intgrid.setAdapter(saa);
}
This works fine but because I have date comparison queries so I store my dates as "yyyy-MM-dd" but what I want to show is "MMM-dd-yyyy".
I already know how to do this but my problem is I don't know how to do this before my SimpleCursorAdapter starts populating my GridView.
This is what I was hoping to use before my SimpleCursorAdapter starts populating the GridView:
try {
DateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date input = inputFormat.parse(date);
DateFormat outputFormat = new SimpleDateFormat(" MMM-dd-yyyy ", Locale.ENGLISH);
String finaldate = outputFormat.format(input);
txtDate.setText(finaldate);
} catch (Exception ex) {
Alerts.CatchError(AccountDetails.this, ex.toString());
}
Aucun commentaire:
Enregistrer un commentaire