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.
Create your Calendar with correct time zone:
Calendar calendar1 = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With