I want to print the Time (hours:minutes:seconds) from a date gotten from a String.
I have a string with the next value:
String dateStr = "Tue, 04 Aug 2015 12:09:10 GMT"
I parse it to a Date:
SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH);
Date d = format.parse(dateStr);
But when I try to get the hours, minutes and seconds, I get a different value:
System.out.println("The current time is: " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds());
Prints: "The current time is: 9:9:10"
Whats wrong? Shouldn't print "The current time is: 12:9:10"?
Thanks :)
More information:
When I create the Date, it automatically sets the Timezone to GMT-03:00 2015, and that's why is printing 3 hours less. How can I set the timezone?