Here you can find the source of getFirstDay(boolean isNeedHH24MISS)
public static String getFirstDay(boolean isNeedHH24MISS)
//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(); } }