get First Day Of Month - Java java.util

Java examples for java.util:Month

Description

get First Day Of Month

Demo Code


//package com.java2s;

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

public class Main {
    public static void main(String[] argv) throws Exception {
        Date today = new Date();
        System.out.println(getFirstDayOfMonth(today));
    }/*from  w ww . ja  v  a  2s  .com*/

    public static Date getFirstDayOfMonth(Date today) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(today);

        calendar.set(Calendar.DAY_OF_MONTH, 1);

        return calendar.getTime();
    }
}

Related Tutorials