get Month value in MM format - Android java.util

Android examples for java.util:Month

Description

get Month value in MM format

Demo Code

import android.content.Context;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class Main{

    public static int getMM() {
        SimpleDateFormat sdf = new SimpleDateFormat("mm");
        sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
        return Integer.parseInt(sdf.format(new Date()));
    }//from  w  w w.j a  v a 2 s . c om

}

Related Tutorials