Java Calendar Create getCalendarBefore(int i)

Here you can find the source of getCalendarBefore(int i)

Description

get Calendar Before

License

Apache License

Declaration

public static Calendar getCalendarBefore(int i) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;
import java.util.Date;

public class Main {
    private static final String a = "yyyy-MM-dd HH:mm:ss:SSS";

    public static Calendar getCalendarBefore(Date date, int i) {
        Calendar calendar;/*  w  w  w  . j  a v  a2  s  .com*/
        (calendar = Calendar.getInstance()).setTime(date);
        return getCalendarBefore(calendar, i);
    }

    public static Calendar getCalendarBefore(int i) {
        return getCalendarBefore(Calendar.getInstance(), i);
    }

    public static Calendar getCalendarBefore(Calendar calendar, int i) {
        calendar.add(5, -1 * i);
        return a(calendar);
    }

    private static Calendar a(Calendar calendar) {
        calendar.set(11, 0);
        calendar.clear(12);
        calendar.clear(13);
        calendar.clear(14);
        return calendar;
    }
}

Related

  1. getCalendar(String str)
  2. getCalendar(String time, char sep, boolean isStart)
  3. getCalendar(String yyyy, String mm, String dd)
  4. getCalendar(TimeZone timeZone, Locale locale)
  5. getCalendarAtMidnight(Date d)
  6. getCalendarByName(String timeZone)
  7. getCalendarBySpecific(int year, int month, int date, int hour)
  8. getCalendarByValue(String timeZone)
  9. getCalendarDate()