get First Day Of This Month - Android java.util

Android examples for java.util:Month

Description

get First Day Of This Month

Demo Code


//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {
    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");

    public static String getFirstDayOfThisMonth() {
        String str = "";
        Calendar lastDate = Calendar.getInstance();
        lastDate.set(Calendar.DATE, 1);//
        // lastDate.add(Calendar.MONTH,-1);//
        // lastDate.add(Calendar.DATE,-1);//

        str = sdf.format(lastDate.getTime());
        return str;
    }//from  w  w w .  j a  v a2  s  . c  o  m
}

Related Tutorials