Java Day in Month firstDayOfNextMonth(String dateFormat)

Here you can find the source of firstDayOfNextMonth(String dateFormat)

Description

get first day of next month in specified date format.

License

Apache License

Parameter

Parameter Description
dateFormat the formatter of date, such as:yyyy-MM-dd HH:mm:ss:SSS.

Declaration

public static String firstDayOfNextMonth(String dateFormat) 

Method Source Code


//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());
    }
}

Related

  1. daysOfMonth(int year)
  2. daysOfMonth(int year, int month)
  3. firstDayOfLastMonth()
  4. firstDayOfMonth(int commonMonthIndx, int iyear)
  5. firstDayOfMonth(int year, int month, String dateFormat)
  6. getCountDayForMonth(int year, int month)
  7. GetDay(int month)
  8. getDayByOfSomeMonth(String curday, int month)
  9. getDayMonth(String dayofmonth)