Hey all
I need to get a time, convert it to GMT, and output it in Military time format.
here is what we have been using.
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(startDate.getTime()
- calendar.get(Calendar.ZONE_OFFSET));
// startdate is initialized elsewhere
The problem is our times have become an hour off, probably because we changed over to Daylight savings or something and GMT doesnt do that.
The time on the box is correct.
Ive been playing with
calendar.setTimeZone(new SimpleTimeZone(0, "GMT"));
calendar.setTime(new Date());
LOG.info(calendar.getTime()); // output correct GMT time, but not military format
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.FULL,
DateFormat.DEFAULT);
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
edit: This is not outputting correct GMT time; I thought it was but looked it over and it wasn't.
Anyone know the answer? I dont see anything obvious in the API to do that.
Message was edited by:
shrndegruv