Java Month Day getShortFirstDayOfMonth()

Here you can find the source of getShortFirstDayOfMonth()

Description

get Short First Day Of Month

License

Open Source License

Declaration

public static String getShortFirstDayOfMonth() 

Method Source Code


//package com.java2s;
import java.text.DateFormat;

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

public class Main {
    public final static String shortFormat = "yyyyMMdd";

    public static String getShortFirstDayOfMonth() {
        Calendar cal = Calendar.getInstance();
        Date dt = new Date();

        cal.setTime(dt);/*from   ww  w .j  a  v a 2 s .c o  m*/
        cal.set(Calendar.DAY_OF_MONTH, 1);

        DateFormat df = getNewDateFormat(shortFormat);

        return df.format(cal.getTime());
    }

    public static DateFormat getNewDateFormat(String pattern) {
        DateFormat df = new SimpleDateFormat(pattern);

        df.setLenient(false);
        return df;
    }

    public static String format(Date date, String format) {
        if (date == null) {
            return null;
        }

        return new SimpleDateFormat(format).format(date);
    }
}

Related

  1. getMonthLastDay(String fmt)
  2. getMonthMaxDay(String sDate)
  3. getMonthWeek(String curday)
  4. getMonthWeek(String curday)
  5. getPreviosMonthFirstDay()
  6. getStringOfFirstDayInMonth()
  7. getStringOfFirstDayInMonth()
  8. isFirstDayOfMonth()
  9. isLastDayOfMonth()