Java Day Next getNextDay(String date)

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

Description

get Next Day

License

Open Source License

Declaration

public static String getNextDay(String date) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {
    public static String getNextDay(String date) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {//from   w  w  w. ja  va 2s.c  o  m
            long time = format.parse(date).getTime();
            Calendar cal = Calendar.getInstance();
            cal.setTimeInMillis(time);
            cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
            cal.add(Calendar.DAY_OF_MONTH, 1);
            return format.format(cal.getTime());
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static long getTime(String time) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            return format.parse("1970-01-01 " + time).getTime() - format.parse("1970-01-01 00:00:00").getTime();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return 0;
    }
}

Related

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