001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.util;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    
019    import java.util.Calendar;
020    import java.util.Locale;
021    import java.util.TimeZone;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     * @author Marcellus Tavares
026     */
027    public class CalendarFactoryUtil {
028    
029            public static Calendar getCalendar() {
030                    return getCalendarFactory().getCalendar();
031            }
032    
033            public static Calendar getCalendar(int year, int month, int date) {
034                    return getCalendarFactory().getCalendar(year, month, date);
035            }
036    
037            public static Calendar getCalendar(
038                    int year, int month, int date, int hour, int minute) {
039    
040                    return getCalendarFactory().getCalendar(
041                            year, month, date, hour, minute);
042            }
043    
044            public static Calendar getCalendar(
045                    int year, int month, int date, int hour, int minute, int second) {
046    
047                    return getCalendarFactory().getCalendar(
048                            year, month, date, hour, minute, second);
049            }
050    
051            public static Calendar getCalendar(
052                    int year, int month, int date, int hour, int minute, int second,
053                    int millisecond) {
054    
055                    return getCalendarFactory().getCalendar(
056                            year, month, date, hour, minute, second, millisecond);
057            }
058    
059            public static Calendar getCalendar(
060                    int year, int month, int date, int hour, int minute, int second,
061                    int millisecond, TimeZone timeZone) {
062    
063                    return getCalendarFactory().getCalendar(
064                            year, month, date, hour, minute, second, millisecond, timeZone);
065            }
066    
067            public static Calendar getCalendar(Locale locale) {
068                    return getCalendarFactory().getCalendar(locale);
069            }
070    
071            public static Calendar getCalendar(long time) {
072                    return getCalendarFactory().getCalendar(time);
073            }
074    
075            public static Calendar getCalendar(long time, TimeZone timeZone) {
076                    return getCalendarFactory().getCalendar(time, timeZone);
077            }
078    
079            public static Calendar getCalendar(TimeZone timeZone) {
080                    return getCalendarFactory().getCalendar(timeZone);
081            }
082    
083            public static Calendar getCalendar(TimeZone timeZone, Locale locale) {
084                    return getCalendarFactory().getCalendar(timeZone, locale);
085            }
086    
087            public static CalendarFactory getCalendarFactory() {
088                    PortalRuntimePermission.checkGetBeanProperty(CalendarFactoryUtil.class);
089    
090                    return _calendarFactory;
091            }
092    
093            public void setCalendarFactory(CalendarFactory calendarFactory) {
094                    PortalRuntimePermission.checkSetBeanProperty(getClass());
095    
096                    _calendarFactory = calendarFactory;
097            }
098    
099            private static CalendarFactory _calendarFactory;
100    
101    }