I am trying to convert a time from one timezone to another
java.text.SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
formatter.setTimeZone();
String formattedDateTime = formatter.format(date);
parseDate(formattedDateTime);
// this all works ok and i get string with correct time in whatever timezone i put in setTimeZone();
private Date parseDate(String dateFormat)
{
Calendar cal = new GregorianCalendar();
cal.set(Calendar.YEAR, substring of dateFormat put to int);
cal.set(Calendar.MONTH, substring of dateFormat put to int);
cal.set(Calendar.DATE, substring of dateFormat put to int);
cal.set(Calendar.HOUR_OF_DAY, substring of dateFormat put to int);
cal.set(Calendar.MINUTE, substring of dateFormat put to int);
return cal.getTime();
}
Ok problem is that cal.getTime returns correct time but wrong timezone so date object returned will have correct time bubt timezone will be GMT so if i change result again to another timeZone it will think its GMT as opposed to its correct timeZone.
Any help appreciated.
Thanks,
Carl