How to convert time in milliseconds to month in Java

1 Answer

0 votes
package javaapplication1;

import java.util.Calendar;

public class JavaApplication1 {

    public static void main(String[] args) {

        Calendar cal = Calendar.getInstance();
        
        // Set time in milliseconds
        cal.setTimeInMillis(1476907455894L);
        
        int month = cal.get(Calendar.MONTH) + 1; 
        System.out.println(month);
        
    }
}

/*

run:

10

*/

 



answered Oct 20, 2016 by avibootz

Related questions

1 answer 160 views
1 answer 186 views
2 answers 772 views
1 answer 132 views
...