I was looking for a way to get current time in various timezones based on an user input. I know I could use Joda Time! but is that the only way?
Isn\'t there an option
As Jon pointed out the method getTime()
is returning a java.util.Date
object which is just a millisecond value and not timezone aware.
If you are just looking at printing the times then you can use the calendar and manually get the fields you want like
System.out.println(utc.get(Calendar.HOUR_OF_DAY) + ":" + utc.get(Calendar.MINUTE))
This would need some formatting for a minute < 10 to display the 0