Java Day of getFirstDay(boolean withTime)

Here you can find the source of getFirstDay(boolean withTime)

Description

get First Day

License

Open Source License

Declaration

public static String getFirstDay(boolean withTime) 

Method Source Code


//package com.java2s;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {

    public static String getFirstDay(boolean withTime) {

        String formatStr = "yyyy-MM-dd";
        if (withTime) {
            formatStr += " HH:mm:ss";
        }//w ww .  java  2s.co  m
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat datef = new SimpleDateFormat(formatStr);
        cal.set(GregorianCalendar.DAY_OF_MONTH, 1);
        Date beginTime = cal.getTime();

        return datef.format(beginTime);
    }
}

Related

  1. getDeltaDays(String date)
  2. getDeltaNow(int deltaDays)
  3. getDisplayDate(final Date date, final int offsetDays)
  4. getEndDayofMouth(String date, String inPattern, String outPattern)
  5. getFirstDay(boolean isNeedHH24MISS)
  6. getFirstDay(Date date)
  7. getFirstDayInThisQuarter(String nowDate)
  8. getFirstDayOfQuarter(Date date)
  9. getFirstOfDay(Date date)