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.
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.
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);
System.out.println(date);
} catch (ParseException e) {
e.printStackTrace();
}
DateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd");
DateFormat outputFormat = new SimpleDateFormat("dd MMM yyyy");
String inputDateStr="2011-01-11";
Date date = inputFormat.parse(inputDateStr);
String outputDateStr = outputFormat.format(date);
from 2011-01-11
to 11 Jan 2011
refer to https://developer.android.com/reference/android/icu/text/SimpleDateFormat.html
to find the pattern of the date from your sql and the new pattern you want