Reputation: 679
I am trying to convert my time in minutes to HH:MM. For example 418minutes = 6:58. I am using following code:
long milli = PriemCas*60000;
Calendar calendar1 = Calendar.getInstance();
calendar1.setTimeInMillis(milli);
int hours3 = calendar1.get(Calendar.HOUR_OF_DAY);
int minutes3 = calendar1.get(Calendar.MINUTE);
System.out.println(hours3+":"+minutes3);
I get 7:58 when my variable PriemCas = 418 instead of 6:58. What could be wrong here? Thank you very much.
Upvotes: 5
Views: 3583
Reputation: 35960
Create your Calendar with correct time zone:
Calendar calendar1 = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
Upvotes: 14