Java Month Get getMonthFirstDate(final Date date, final String format)

Here you can find the source of getMonthFirstDate(final Date date, final String format)

Description

get Month First Date

License

Apache License

Declaration

public static String getMonthFirstDate(final Date date, final String format) 

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 Date getMonthFirstDate(final Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);/* ww w  . j av a2 s.  co  m*/
        calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), 1, 0, 0, 0);
        return calendar.getTime();
    }

    public static String getMonthFirstDate(final Date date, final String format) {
        Date monthFirstDate = getMonthFirstDate(date);
        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
        return dateFormat.format(monthFirstDate);
    }
}

Related

  1. getMonthDesc(Date month)
  2. getMonthEnd(Date date)
  3. getMonthEnd(String strdate)
  4. getMonthEnd(String strdate)
  5. getMonthEndDate(Date date)
  6. getMonthForDate(String dateToCheck, String pattern)
  7. getMonthForInt(int num)
  8. getMonthForString(String monthStr, Locale locale)
  9. getMonthInfo(int monthInfo)