Java Month Day getFirstDayOfMonth(Long date)

Here you can find the source of getFirstDayOfMonth(Long date)

Description

get First Day Of Month

License

Apache License

Declaration

public static Long getFirstDayOfMonth(Long date) 

Method Source Code

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

import java.util.*;

public class Main {
    public static Long getFirstDayOfMonth(Long date) {
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(date);/*from  w w  w. j  a v  a 2 s. c  o  m*/
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.clear(Calendar.MINUTE);
        cal.clear(Calendar.SECOND);
        cal.clear(Calendar.MILLISECOND);
        cal.set(Calendar.DAY_OF_MONTH, Calendar.getInstance().getActualMinimum(Calendar.DAY_OF_MONTH));
        return cal.getTimeInMillis();
    }

    public static Date getFirstDayOfMonth(Date date) {
        long time = getFirstDayOfMonth(date.getTime());
        return new Date(time);
    }
}

Related

  1. getFirstDayOfMonth(Date date)
  2. getFirstDayOfMonth(Date date)
  3. getFirstDayOfMonth(Date date)
  4. getFirstDayOfMonth(Date date)
  5. getFirstDayOfMonth(Date date)
  6. getFirstDayOfNextMonth()
  7. getFirstDayStringOfMonth(Date date)
  8. getFirstDayStrOfMonth(Date date)
  9. getLastMonthDay()