Please find my below Code what is does is it takes the TimeStamp Value of any timeZone Converts it to required TimeZone and gives you the Date of requiredTime Zone . It works the date variable is coming correctly but I need the value in (Date) Datatype so am parsing it back using the same SimpleDataFormat object but its returning me a value in different Format not the one mentioned in the SimpleDataFormat Object .
private Date getDateOfTimeZone(Timestamp timeStamp, String timeZoneCode)
throws ParseException {
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd-MM-yy");
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone(timeZoneCode));
String date = DATE_FORMAT.format(timeStamp);
return DATE_FORMAT.parse(date);
}
Input Varibles : TimeStamp : 2013-11-01 16:19:37.0 , TimeZone : "IST"
Date value is coming as : 02-11-13 (Correct)
But Parse() is returning me : Fri Nov 01 14:30:00 EDT 2013.
I can see the date is converted according to timeZone but why parse is not returning it in required format i.e "dd-MM-yy".