Date Format Types in android

All Possible Format for Date Converter :-
final String[] possibleFormats = {
"EEE, dd MMM yyyy HH:mm:ss z", // RFC_822
"EEE, dd MMM yyyy HH:mm zzzz",
"yyyy-MM-dd'T'HH:mm:ssZ",
"yyyy-MM-dd'T'HH:mm:ss.SSSzzzz", // Blogger Atom feed has millisecs also
"yyyy-MM-dd'T'HH:mm:sszzzz",
"yyyy-MM-dd'T'HH:mm:ss z",
"yyyy-MM-dd'T'HH:mm:ssz", // ISO_8601
"yyyy-MM-dd'T'HH:mm:ss",
"yyyy-MM-dd'T'HHmmss.SSSz",
"yyyy-MM-dd"
};


Function how to change :-

String inputPattern = "yyyy-MM-dd'T'HH:mm:ssZ";
String outputPattern = "dd-MM-yyyy HH:mm:ss";
SimpleDateFormat inputFormat = new SimpleDateFormat(inputPattern);
SimpleDateFormat outputFormat = new SimpleDateFormat(outputPattern);

Date date = null;
String str = null;

try {
date = inputFormat.parse(orderDate);
orderDate = outputFormat.format(date);
} catch (ParseException e) {
e.printStackTrace();
}

Comments

Popular posts from this blog

How to Fix ‘This file name is too long’ Error?

General Knowledge