Here you can find the source of getFirstDayOfThisMonth()
public static String getFirstDayOfThisMonth()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.*; public class Main { static SimpleDateFormat sdfShort = new SimpleDateFormat("yyyyMMdd"); public static String getFirstDayOfThisMonth() { try {/*from w ww.j a va 2 s.c om*/ return getNowShortDate().substring(0, 6) + "01"; } catch (Exception e) { return ""; } } public static String getNowShortDate() throws Exception { String nowDate = ""; try { java.sql.Date date = null; date = new java.sql.Date(new Date().getTime()); nowDate = sdfShort.format(date); return nowDate; } catch (Exception e) { throw e; } } /** * Returns a string the represents the passed-in date parsed according to * the passed-in format. Returns an empty string if the date or the format * is null. **/ public static String format(Date aDate, SimpleDateFormat aFormat) { if (aDate == null || aFormat == null) { return ""; } synchronized (aFormat) { return aFormat.format(aDate); } } }