get Tomorrow - Java java.util

Java examples for java.util:Day

Description

get Tomorrow

Demo Code


//package com.java2s;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static void main(String[] argv) throws Exception {
        Date date = new Date();
        System.out.println(getTomorrow(date));
    }/*from w  w w  .j a v a 2  s.c om*/

    private static SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");

    public static String getTomorrow(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) + 1);
        date = cal.getTime();
        return sf.format(date);
    }
}

Related Tutorials