Java Month Day getFirstDayStrOfMonth(Date date)

Here you can find the source of getFirstDayStrOfMonth(Date date)

Description

get First Day Str Of Month

License

Apache License

Declaration

public static String getFirstDayStrOfMonth(Date date) 

Method Source Code

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

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

public class Main {

    public static String getFirstDayStrOfMonth(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);/*from ww  w  . jav  a  2 s  .  c o m*/
        calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));

        return formatDate2Str(calendar.getTime());
    }

    public static String formatDate2Str(Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

        return sdf.format(date);
    }
}

Related

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