Java Day of getFirstDay(boolean isNeedHH24MISS)

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

Description

get First Day

License

Open Source License

Declaration

public static String getFirstDay(boolean isNeedHH24MISS) 

Method Source Code

//package com.java2s;
/*/*from w w  w .j  av  a  2  s.  c om*/
 * Copyright 1998-2012 360buy.com All right reserved. This software is the confidential and proprietary information of
 * 360buy.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the license agreement you entered into with 360buy.com.
 */

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

public class Main {
    public final static String YYYY_MM_DD = "yyyy-MM-dd";

    public static String getFirstDay(boolean isNeedHH24MISS) {
        SimpleDateFormat df = new SimpleDateFormat(YYYY_MM_DD);
        Calendar calendar = Calendar.getInstance();
        Date theDate = calendar.getTime();
        GregorianCalendar gcLast = (GregorianCalendar) Calendar.getInstance();
        gcLast.setTime(theDate);
        gcLast.set(Calendar.DAY_OF_MONTH, 1);
        String day_first = df.format(gcLast.getTime());
        StringBuffer str = new StringBuffer().append(day_first);
        if (isNeedHH24MISS) {
            str.append(" 00:00:00");
        }
        return str.toString();
    }
}

Related

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