greetings all i am using the following method to get the current time in GMT timezone
public static Timestamp getCurrentTimeGMT() {
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
long time = c.getTimeInMillis();
long offset = TimeZone.getDefault().getOffset(time);
return new Timestamp(time - offset);
}
but when i try to use the same method with minor changes to get the current time in GMT+3 it gives me the same result of GMT ? i don't know why:
public static Timestamp getCurrentTimeGMT3() {
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT+3"));
long time = c.getTimeInMillis();
long offset = TimeZone.getDefault().getOffset(time);
return new Timestamp(time - offset);
}
any ideas why the above code doesn't work properly, and how to do such a method ?