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

Open Source License

Declaration


public static String getNextDay(String nowdate, String delay) 

Method Source Code


//package com.java2s;

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

public class Main {

    public static String getNextDay(String nowdate, String delay) {

        try {//from w  ww. j a  v  a  2 s  .co  m

            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) {

        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

        ParsePosition pos = new ParsePosition(0);

        Date strtodate = formatter.parse(strDate, pos);

        return strtodate;

    }

    public static String getTime() {

        Date currentTime = new Date();

        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String dateString = formatter.format(currentTime);

        String min;

        min = dateString.substring(14, 16);

        return min;

    }

    public static String format(java.util.Date date, String format, Calendar calendar) {
        String result = "";
        try {
            if (date != null) {
                java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(format);
                if (calendar != null) {
                    sdf.setCalendar(calendar);
                }
                result = sdf.format(date);
            }
        } catch (Exception e) {
        }

        return result;
    }

    public static String format(java.util.Date date, String format) {
        return format(date, format, null);
    }

    public static String format(long times, String format) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(times);
        return format(calendar.getTime(), format);
    }
}

Related

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