String date1 = "13/03/2014 16:56:46 AEDT";
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss z");
sdf.setTimeZone(TimeZone.getTimeZone("GMT+12"));
java.util.Date convertedDate = (java.util.Date) sdf.parse(date1);
SimpleDateFormat outFormatter = new SimpleDateFormat("EE MMM dd yyyy HH:mm:ss z");
outFormatter.setTimeZone(TimeZone.getTimeZone("GMT+12"));
String output = outFormatter.format(convertedDate);
System.out.println("Date in NZ Timezone : " + output);
I am trying to convert AEDT date into dd/MM/yyyy HH:mm:ss z but it gives me exception :
Exception in thread "main" java.text.ParseException: Unparseable date: "13/03/2014 16:56:46 AEDT" at java.text.DateFormat.parse(DateFormat.java:337)
Please help me with this....
I need to convert users time in to my UTC time for making it same through my web-application ...
Your code seems to be right, but AEDT is not a valid General Time Zone. Thats the reason for the
java.text.ParseException
. Instead you can do:Input:
13/03/2014 16:56:46 GMT+12:00
Output:
Date in NZ Timezone : Fr Mrz 14 2014 15:56:46 GMT+12:00
It seems to work right:)
From the Doc's:
It means that Java does not support AEDT abbreviation, but since you know timezone offset you can doit this way