Surendar D Surendar D - 4 months ago 40
Android Question

How to parse date following format

How do parse this date format Thu Dec 01 00:00:00 GMT+05:30 2016 to normal date, month and year format.


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