I have milliseconds in String and i want to get hour and minutes from it.
This is my code
:
String ms = "1425652847915";
int t = Integer.parseInt(ms);
Calendar c = Calendar.getInstance();
c.set(Calendar.MILLISECOND, t);
int h = c.get(Calendar.HOUR_OF_DAY);
int m = c.get(Calendar.MINUTE);
But i got this error
:
java.lang.NumberFormatException: unable to parse '1425652847915' as integer
Any suggestion?
Obviously 1425652847915
is greater than Integer.MAX_VALUE
but you still need to set the time for Calendar
long t = Long.parseLong("1425652847915");
Calendar c = Calendar.getInstance();
c.setTimeInMillis(t);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments