get Month from Date and return int - Android java.util

Android examples for java.util:Month

Description

get Month from Date and return int

Demo Code


//package com.java2s;

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static int getMonth(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);/*from w w  w .j a  v  a 2s  .  co m*/
        return c.get(Calendar.MONTH) + 1;
    }
}

Related Tutorials