Java Day Next getNextDay(String day)

Here you can find the source of getNextDay(String day)

Description

get Next Day

License

Apache License

Declaration

public static String getNextDay(String day) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    public static String getNextDay(String day) {
        return getDeltaDay(day, 1);
    }/* w  w  w  . j a va2 s .  c o  m*/

    public static String getDeltaDay(String day, int delta) {
        GregorianCalendar rightNow = new GregorianCalendar(Integer.parseInt(day.substring(0, 4)),
                Integer.parseInt(day.substring(4, 6)) - 1, Integer.parseInt(day.substring(6, 8)));
        rightNow.add(Calendar.DAY_OF_YEAR, delta);
        return getDefaultDateFormat().format(rightNow.getTime());
    }

    public static String format(Date date, String formatPattern) {
        if (date == null) {
            return "";
        } else {
            return new SimpleDateFormat(formatPattern).format(date);
        }
    }

    public static SimpleDateFormat getDefaultDateFormat() {
        return new SimpleDateFormat("yyyyMMdd");
    }
}

Related

  1. getNextDay(Date date)
  2. getNextDay(Date date)
  3. getNextDay(Date nowdate, int delay)
  4. getNextDay(String date)
  5. getNextDay(String dateStr)
  6. getNextDay(String nowdate, String delay)
  7. getNextDay(String nowdate, String delay)
  8. getNextDay(String nowdate, String delay)
  9. getNextDay(String nowdate, String delay)