Here you can find the source of getFirstDayOfNextMonth()
public static String getFirstDayOfNextMonth()
//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 getFirstDayOfNextMonth() { try {/* w ww .j ava 2 s .com*/ return increaseYearMonth(getNowShortDate().substring(0, 6)) + "01"; } catch (Exception e) { return ""; } } public static String increaseYearMonth(String yearMonth) { int year = (new Integer(yearMonth.substring(0, 4))).intValue(); int month = (new Integer(yearMonth.substring(4, 6))).intValue(); month = month + 1; if (month <= 12 && month >= 10) return yearMonth.substring(0, 4) + (new Integer(month)).toString(); else if (month < 10) return yearMonth.substring(0, 4) + "0" + (new Integer(month)).toString(); else //if(month>12) return (new Integer(year + 1)).toString() + "0" + (new Integer(month - 12)).toString(); } public static String increaseYearMonth(String yearMonth, int addMonth) { int year = (new Integer(yearMonth.substring(0, 4))).intValue(); int month = (new Integer(yearMonth.substring(4, 6))).intValue(); month = month + addMonth; year = year + month / 12; month = month % 12; if (month <= 12 && month >= 10) return year + (new Integer(month)).toString(); else return year + "0" + (new Integer(month)).toString(); } 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); } } }