Java Day Next getNextDay(String nowdate, String delay)

Here you can find the source of getNextDay(String nowdate, String delay)

Description

get Next Day

License

Apache License

Declaration

public static String getNextDay(String nowdate, String delay) 

Method Source Code

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

import java.text.ParsePosition;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static final SimpleDateFormat FORMATTER_SHORT = new SimpleDateFormat("yyyy-MM-dd");
    public static final SimpleDateFormat FORMATTER_LONG = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static String getNextDay(String nowdate, String delay) {
        try {//from  w ww  . j av  a2 s .  com
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            String mdate = "";
            Date d = strToDate(nowdate);
            long myTime = (d.getTime() / 1000) + Integer.parseInt(delay) * 24 * 60 * 60;
            d.setTime(myTime * 1000);
            mdate = format.format(d);
            return mdate;
        } catch (Exception e) {
            return "";
        }
    }

    public static Date strToDate(String strDate) {
        ParsePosition pos = new ParsePosition(0);
        Date strtodate = FORMATTER_SHORT.parse(strDate, pos);
        return strtodate;
    }

    public static String getTime() {
        Date currentTime = new Date();
        String dateString = FORMATTER_LONG.format(currentTime);
        String min;
        min = dateString.substring(14, 16);
        return min;
    }
}

Related

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