Not able to parse String date of format IST and GMT format

java date format
string to date java
how to convert string to date in java 8 in yyyy-mm-dd format
how to convert string to date in java in yyyy-mm-dd format
utc string to date java
java convert date to utc timezone
java 8 date format
how to convert string to a particular date format in java

Not able to parse String date Sun Dec 06 11:15:00 IST 2015 using SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy") when I use Locale.ENGLISH in SimpleDateFormat without Locale.ENGLISH working but

Not able parse when app language changes to non-English language like Marathi/Hindi.

I am able to parce other string date like 10 12 2018 to dd MM yyyy but not above format.

Facing issue on Lollipop and kit-kat devices. when I change Locale to non-English language.

minSdkVersion 16 and targetSdkVersion 27

1.Tried following solutions.

EEE MMM dd HH:mm:ss Z yyyy ,EEE MMM dd HH:mm:ss z yyyy ,DateFormat etc

String tDueDate="Sun Dec 06 11:15:00 IST 2015"; 
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH);
        Date dt = sdf.parse(tDueDate);
        sdf = new SimpleDateFormat("dd MMM yyyy", Locale.ENGLISH);
        return sdf.format(dt);

Sat Oct 03 00:00:00 IST 2018 12-12 13:16:33.733 17653-17653/com.smartsms.organizer.events W/System.err: java.text.ParseException: Unparseable date: "Sat Oct 03 00:00:00 IST 2018" (at offset 20) 12-12 13:16:33.733 17653-17653/com.smartsms.organizer.events W/System.err: at java.text.DateFormat.parse(DateFormat.java:555) 12-12 13:16:33.733 17653-17653/com.smartsms.organizer.events W/System.err: at com.smartsms.util.EventsUtil.returnDateInDateFormat(EventsUtil.java:750) 12-12 13:16:33.733 17653-17653/com.smartsms.organizer.events W/System.err: at com.smartsms.fragment.EventsFragmentNew$MyTask.onPostExecute(EventsFragmentNew.java:1397) 12-12 13:16:33.733 17653-17653/com.smartsms.organizer.events W/System.err: at com.smartsms.fragment.EventsFragmentNew$MyTask.onPostExecute(EventsFragmentNew.java:1295) 12-12 13:16:33.733 17653-17653/com.smartsms.organizer.events W/System.err: at android.os.AsyncTask.finish(AsyncTask.java:632) 12-12 13:16:33.733 17653-17653/com.smartsms.organizer.events W/System.err: at android.os.AsyncTask.access$600(AsyncTask.java:177) 12-12 13:16:33.733 17653-17653/com.smartsms.organizer.events W/System.err: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645) 12-12 13:16:33.733 17653-17653/com.smartsms.organizer.events W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102) 12-12 13:16:33.733 17653-17653/com.smartsms.organizer.events W/System.err: at android.os.Looper.loop(Looper.java:136) 12-12 13:16:33.733 17653-17653/com.smartsms.organizer.events W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5111) 12-12 13:16:33.733 17653-17653/com.smartsms.organizer.events W/System.err: at java.lang.reflect.Method.invokeNative(Native Method) 12-12 13:16:33.733 17653-17653/com.smartsms.organizer.events W/System.err: at java.lang.reflect.Method.invoke(Method.java:515) 12-12 13:16:33.733 17653-17653/com.smartsms.organizer.events W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:806) 12-12 13:16:33.733 17653-17653/com.smartsms.organizer.events W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622) 12-12 13:16:33.733 17653-17653/com.smartsms.organizer.events W/System.err: at dalvik.system.NativeStart.main(Native Method) 12-12 13:16:33.733 17653-17653/com.smartsms.organizer.events

Activitylocale: en_US


try with change code like

 SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", Locale.getDefault());
        Date dt = sdf.parse(tDueDate);
        sdf = new SimpleDateFormat("dd MMM yyyy", Locale.getDefault());
        return sdf.format(dt);

SimpleDate Format parsing error, no! dude it's not working for me it's only give cast parse error – Ravi Patel Apr 12 '​16 at 7:29 If you are feeding date as "Fri Apr 08 2016 00:00:00 GMT+0530 (IST​)". The correct parse-able date string should be: SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd yyyy HH:mm:ss z (Z)"); String strDate  Java 8 – Parse string to date-time in UTC By Lokesh Gupta | Filed Under: Java Date/Time Learn to parse a given date time string to instance e.g. ZonedDateTime or OffsetDateTime classes, using DateTimeFormatter class in Java 8.


you could have a try like this:

SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH);

change to :

SimpleDateFormat sdf1 = new SimpleDateFormat ("EEE MMM dd HH:mm:ss 'IST' yyyy", Locale.ENGLISH);

Not able to parse String date of format IST and GMT format, 1.Tried following solutions. SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", Locale.getDefault()); Date dt = sdf.parse(tDueDate); sdf = new SimpleDateFormat("dd MMM yyyy", Locale.getDefault()); return sdf.format(dt); For the Java APIs, the pattern specifiers are generally documented with the formatting classes themselves; for .NET’s built-in classes you want the custom date and time format strings and standard date and time format strings MSDN pages, and for Noda Time follow the various options from the text handling part of the user guide. (For other platforms, use your common sense. :)


String dateStr = "Sun Dec 06 11:15:00 IST 2015";
DateFormat formatter = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy");
Date date = (Date)formatter.parse(dateStr);
System.out.println(date);

Java 8 - Parse string to date-time in UTC (or GMT), Learn to parse a given date time string to instance e.g. ZonedDateTime or OffsetDateTime classes, using Date time with full zone information is represented in following formats. In this example, timestamp represents one instant at "+05:30" offset i.e. IST. [/java] tags otherwise code may not appear partially or even fully. NewComer_forum wrote: I tried with below code but throwing exceptions String g = date.toGMTString(); SimpleDateFormat date1 = new SimpleDateFormat(g); You of course read the Javadoc, and so know that the argument to the constructor SimpleDateFormat(String) is the pattern by which you want to parse, and not the string you want to parse itself, right?


I was looking for answer why its not able to parce String Sun Dec 06 11:15:00 IST 2015 using SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy") other date formats like String date 01 10 2018 this with dd MM YYYY format able to parce but not above. So

I have tried this alternative way to get respective date format.

Hope this will help some one

value is date object

Date date   = d.parse(value);
Calendar c = Calendar.getInstance();
c.setTime(date);
int dd = c.get(Calendar.DAY_OF_MONTH);
int mmm = c.get(Calendar.MONTH) + 1;
int yyyy = c.get(Calendar.YEAR);

String dateString = "" + dd + "-" + mmm + "-" + yyyy;

java.text.DateFormat.parse java code examples, DateFormat format = new SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH); Date date = format.parse(string); date = format.parse(string); System.out.println(​date); // Sat Jan 02 00:00:00 GMT 2010 Specifies whether or not date/time parsing shall be lenient. An exception that indicates a failed JDBC operation. The input string format is defined in the ISO 8601 standard, a family of date-time formats. Avoid old date-time classes. The Question and other Answers use old outmoded date-time classes bundled with the earliest versions of Java. Avoid them. Now supplanted by the java.time classes. Using java.time. Your input string ends with an offset-from-UTC.


How to format Date in Java, You can format date on any String format based upon various attribute and provide format() and parse() method to convert Date to and from String in Java. Worth noting is that SimpleDateFormat is not thread-safe and should not be shared we first needs to define a String date format e.g. "dd-MM-yyyy" will print dates in  That doesn't mean anything, since a Date object doesn't have any format at all. There is no such concept as the "format" of a Date object. when you convert the string back to date it is still coming up with Tue May 05 00:00:00 GMT+05:30 2009 but i want it to be 05/05/2009


How to convert Java Date into Specific TimeZone format, Java convert date from one timezone to another, PST to IST, PST to GMT public static String formatDateToString(Date date, String format, String timeZone)  You are parsing the date-time using your local time-zone, and then converting the result to UTC. As a result, the local time is shifted back 5.5 hours. Try changing the formatter line to As a result, the local time is shifted back 5.5 hours.


Convert String to Date, Date to String in Java, Convert String to Date in Java, Convert Date to String in Java, Java String to Date​, Java Date to String, java date format string, java parse string to date. For converting Date to String, we use format(Date date) method. 10:45:30 Date Object = Sun Oct 14 00:00:00 IST 2012 ABC is not a valid date null Date Object = null. See the SimpleDateFormat API to understand the difference between h and H, or m and M - it's important. You can also use a plain DateFormat if you want it - just takes several more lines to customize the formate the way you want it.