Get GMT Time in Java
In Java, I want to get the current time in GMT. I tried various options like this: Date date = new Date(); Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); date1 = calendar.getTime(); But the date is always is interpreted in my local time zone. What am I doing wrong and how can I convert a java Date to GMT? Odds are good you did the right stuff on the back end in getting the date, but there's nothing to indicate that you didn't take that GMT time and format it according to your machine's current locale. final Date currentTime = new Date(); final SimpleDateFormat sdf = new