0

I want time with GMT string too.

But Im not able to get it.

DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd/hh-mm");
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
Date date = new Date();
System.out.println("date "+dateFormat.format(date));

But Im getting like this 2015-12-28/11-53 without GMT at the end

user1742919
  • 401
  • 4
  • 11
  • 1
    http://stackoverflow.com/questions/308683/how-can-i-get-the-current-date-and-time-in-utc-or-gmt-in-java – amit prasad Dec 28 '15 at 12:05
  • this has been asked and answered before in (http://stackoverflow.com/questions/308683/how-can-i-get-the-current-date-and-time-in-utc-or-gmt-in-java) – Mark Fitzgerald Jan 09 '16 at 11:32

1 Answers1

2

Use

 DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd/hh-mm z");
 dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));

instead of

DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd/hh-mm");

where 'z' means timezone

Azat Nugusbayev
  • 1,391
  • 11
  • 19