Code example for GregorianCalendar

Methods: getTimesetTimeadd

0
        calendar.add(Calendar.DAY_OF_MONTH, 1);
        return calendar.getTime();
    } 
 
    public static Date nextDay(Date date) {
        GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTime(date);
        calendar.add(Calendar.DAY_OF_MONTH, 1);
        return calendar.getTime();
    } 
 
    public static long daysBefore(Date date) {
        long ms = date.getTime() - System.currentTimeMillis();
        if (ms < 0) {
            return -1; 
        } else { 
            return ms / MS_IN_24H;
        } 
    } 
} 
Experience pair programming with AI  Get Codota for Java