Java Date to Month getMonthBeginDate()

Here you can find the source of getMonthBeginDate()

Description

get Month Begin Date

License

Apache License

Declaration

public static Date getMonthBeginDate() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {

    public static Date getMonthBeginDate(int year, int month) {
        Calendar c = Calendar.getInstance();
        c.set(Calendar.YEAR, year);
        c.set(Calendar.MONTH, month - 1);
        c.set(Calendar.DAY_OF_MONTH, 1);
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        return c.getTime();
    }/*from  www.j  a  va 2s .  c  o m*/

    public static Date getMonthBeginDate() {
        Calendar c = Calendar.getInstance();
        c.set(Calendar.DAY_OF_MONTH, 1);
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        return c.getTime();
    }

    public static long getTime() {

        return (new java.util.Date()).getTime();
    }
}

Related

  1. getMonth(java.util.Date date)
  2. getMonth(java.util.Date date)
  3. getMonth(java.util.Date today)
  4. getMonth(long date, int increment)
  5. getMonth(String strDate)
  6. getMonthBetween(Date data1, Date data2)
  7. getMonthByOffset(Date date, int offset)
  8. getMonthDays(String date)
  9. getMonthFirstDay(Date date)