Here you can find the source of firstDayOfNextMonth(String dateFormat)
Parameter | Description |
---|---|
dateFormat | the formatter of date, such as:yyyy-MM-dd HH:mm:ss:SSS. |
public static String firstDayOfNextMonth(String dateFormat)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { /**// w ww .j a v a 2s . c om * get first day of next month in specified date format. * * @param dateFormat * the formatter of date, such as:yyyy-MM-dd HH:mm:ss:SSS. */ public static String firstDayOfNextMonth(String dateFormat) { Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); cal.add(Calendar.MONTH, 1); cal.set(Calendar.DAY_OF_MONTH, 1); SimpleDateFormat formatter = new SimpleDateFormat(dateFormat); return formatter.format(cal.getTime()); } public static String getTime() { SimpleDateFormat sdf = new SimpleDateFormat("HHmmssSSS"); return sdf.format(new Date()); } }