Reputation: 401
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
Upvotes: 0
Views: 62
Reputation: 1421
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
Upvotes: 2