Get the Month for specify timestamp. - Java java.time

Java examples for java.time:Month

Description

Get the Month for specify timestamp.

Demo Code


//package com.java2s;

import java.time.*;

public class Main {
    /**/*from  w w w.j a  v  a 2 s  .c  o m*/
     * Get the Month for specify timestamp.
     * 
     * @param timestamp
     *          A timestamp need to calculate.
     * @return
     */
    public static int getMonthOfMills(long timestamp) {
        Instant instant = Instant.ofEpochMilli(timestamp);
        ZonedDateTime dateTime = ZonedDateTime.ofInstant(instant,
                ZoneId.systemDefault());
        return dateTime.getMonthValue();
    }
}

Related Tutorials