Java Month of Year getNextMonthFirstDay(String date)

Here you can find the source of getNextMonthFirstDay(String date)

Description

get Next Month First Day

License

Open Source License

Declaration

public static String getNextMonthFirstDay(String date) 

Method Source Code


//package com.java2s;

import java.text.DateFormat;

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    public static final String dateFormat = "yyyy-MM-dd";

    public static String getNextMonthFirstDay(String date) {
        Calendar cal = Calendar.getInstance();
        Date dt = strToDtSimpleFormat(date);
        cal.setTime(dt);//from w  w w. jav  a  2 s.c  om
        cal.add(Calendar.MONTH, 1);
        cal.set(Calendar.DATE, 1);
        return dateFormat(cal.getTime());
    }

    public static final Date strToDtSimpleFormat(String strDate) {
        if (strDate == null) {
            return null;
        }

        try {
            return getFormat(dateFormat).parse(strDate);
        } catch (Exception e) {
        }

        return null;
    }

    public static final String dateFormat(Date date) {
        if (date == null) {
            return "";
        }
        return getFormat(dateFormat).format(date);
    }

    public static final DateFormat getFormat(String format) {
        return new SimpleDateFormat(format);
    }

    public static final String format(Date date, String formate) {
        if (date == null) {
            return "";
        }
        return getFormat(formate).format(date);
    }

    public static final String format(Long dateTmie, String formate) {
        Date date = new Date(dateTmie);
        return getFormat(formate).format(date);
    }
}

Related

  1. getMonthStart(int year, int month)
  2. getNextiMonth(Date date, int month)
  3. getNextMonth()
  4. getNextMonth(Calendar aCal)
  5. getNextMonth(Date nowdate, int delay)
  6. getNextMonthFirstDay(T day)
  7. getNextMonthFistDay(String nowdate, String inFormat, String outFormat)
  8. getNextYearMonth(String yearMonth)
  9. getNrDaysOfMonth(int month, int year)