Saiful Alam Rifan Saiful Alam Rifan - 1 year ago 138
Java Question

How to format datetime from sqlite in android and show on text view

To format date and time which get from sqLite like

2016-07-13 13:10:00
. I want to format it like
07-Jul-2016, 01:10 PM

I have tried lots of solution but I can't find any better format.

Thanks in advance.

Answer Source
  String strCurrentDate= "2016-07-13 13:10:00";
        SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
        Date newDate = null;
        try {
            newDate = format.parse(strCurrentDate);
            format = new SimpleDateFormat("dd-MMM-yyyy hh:mm:ss a");
            String date = format.format(newDate);
        } catch (ParseException e) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download