Java Calendar Adjust adjustCalendar(Calendar calendar)

Here you can find the source of adjustCalendar(Calendar calendar)

Description

adjust Calendar

License

Open Source License

Declaration

private static void adjustCalendar(Calendar calendar) 

Method Source Code


//package com.java2s;

import java.util.Calendar;

public class Main {
    public static final int MILLISECONDS_PER_HOUR = 60 * 60 * 1000;

    private static void adjustCalendar(Calendar calendar) {
        if (calendar.get(Calendar.HOUR_OF_DAY) != 0) {
            if (calendar.get(Calendar.HOUR_OF_DAY) == 1)
                calendar.setTimeInMillis(calendar.getTimeInMillis() - MILLISECONDS_PER_HOUR);
            if (calendar.get(Calendar.HOUR_OF_DAY) == 23)
                calendar.setTimeInMillis(calendar.getTimeInMillis() + MILLISECONDS_PER_HOUR);
        }/*from  w w  w.ja va2 s. c om*/
    }
}

Related

  1. adjustCalendarToLocalTime(Calendar cal)
  2. adjustDate(Calendar calendar, int differenceInDay)
  3. adjustedMillis(Calendar cal)
  4. adjustToDayEnd(Calendar cal)