Java Day From getNextDay(String date)

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

Description

get Next Day

License

Open Source License

Declaration

public final static String getNextDay(String date) 

Method Source Code

//package com.java2s;
/**//from www.  j a v  a  2  s .c o  m
 * @copyright Copyright (C) 2014-2016 City of Bloomington, Indiana. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
 * @author W. Sibo <sibow@bloomington.in.gov>
 *
 */

import java.util.*;

public class Main {
    public final static String getNextDay(String date) {
        String ret = "";
        int mm = 0, dd = 0, yy = 0;
        if (date != null) {
            String[] arr = date.split("/");
            if (arr.length == 3) {
                try {
                    mm = Integer.parseInt(arr[0]);
                    dd = Integer.parseInt(arr[1]);
                    yy = Integer.parseInt(arr[2]);
                    Calendar cal = Calendar.getInstance();
                    cal.set(Calendar.MONTH, (mm - 1));
                    cal.set(Calendar.DATE, dd + 1);
                    cal.set(Calendar.YEAR, yy);

                    mm = cal.get(Calendar.MONTH) + 1;
                    dd = cal.get(Calendar.DATE);
                    yy = cal.get(Calendar.YEAR);
                    ret = mm + "/" + dd + "/" + yy;
                } catch (Exception ex) {
                    System.err.println(ex);
                }
            }
        }
        return ret;
    }
}

Related

  1. getDaysInPastForDate(Date date)
  2. getFirstMilliOfDay(Date date)
  3. getIntervalInDaysSofar(Date from)
  4. getLastDay(Date date)
  5. getNextDay(Date startTime, int n)
  6. getNoonOfDay(Date day)
  7. getPlusDay(String _oneDay, int _aFewDays)
  8. getServerOffset(boolean useDaylightSavingTime)
  9. getTimeField(Date day, int field)