How do parse this date format Thu Dec 01 00:00:00 GMT+05:30 2016 to normal date, month and year format.
ex:
String day = "Thu",
String month= "Dec",
String year= "2016"
How do parse this date format Thu Dec 01 00:00:00 GMT+05:30 2016 to normal date, month and year format.
ex:
String day = "Thu",
String month= "Dec",
String year= "2016"
String input = "Thu Dec 01 00:00:00 GMT+05:30 2016";
SimpleDateFormat parser = new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy");
Date date = parser.parse(input);
You can get the needed data from date. Or as you demand:
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE");
String dayOfWeek = dateFormat.format(date);//Thu
dateFormat = new SimpleDateFormat("MMM");
String month = dateFormat.format(date);//Dec
dateFormat = new SimpleDateFormat("yyyy");
String year = dateFormat.format(date);//2016
Try this:
String strDate = "";
SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
Date date= parser.parse(dateFromDB);
String dayOfTheWeek = (String) android.text.format.DateFormat.format("EEEE", date);
String stringMonth = (String) android.text.format.DateFormat.format("MMM", date);
String intMonth = (String) android.text.format.DateFormat.format("MM", date);
String year = (String) android.text.format.DateFormat.format("yyyy", date);
String day = (String) android.text.format.DateFormat.format("dd", date);
also check these links: Android date parsing (Extracting month and year )
Get Value Of Day Month form Date Object in Android?
How to get the day, year, hours, min Individually from date format "yyyy-MM-dd'T'HH:mm:ss.SSSZ"?