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     */
026    public class CalendarFactoryUtil {
027    
028            public static Calendar getCalendar() {
029                    return getCalendarFactory().getCalendar();
030            }
031    
032            public static Calendar getCalendar(int year, int month, int date) {
033                    return getCalendarFactory().getCalendar(year, month, date);
034            }
035    
036            public static Calendar getCalendar(
037                    int year, int month, int date, int hour, int minute) {
038    
039                    return getCalendarFactory().getCalendar(
040                            year, month, date, hour, minute);
041            }
042    
043            public static Calendar getCalendar(
044                    int year, int month, int date, int hour, int minute, int second) {
045    
046                    return getCalendarFactory().getCalendar(
047                            year, month, date, hour, minute, second);
048            }
049    
050            public static Calendar getCalendar(Locale locale) {
051                    return getCalendarFactory().getCalendar(locale);
052            }
053    
054            public static Calendar getCalendar(TimeZone timeZone) {
055                    return getCalendarFactory().getCalendar(timeZone);
056            }
057    
058            public static Calendar getCalendar(TimeZone timeZone, Locale locale) {
059                    return getCalendarFactory().getCalendar(timeZone, locale);
060            }
061    
062            public static CalendarFactory getCalendarFactory() {
063                    PortalRuntimePermission.checkGetBeanProperty(CalendarFactoryUtil.class);
064    
065                    return _calendarFactory;
066            }
067    
068            public void setCalendarFactory(CalendarFactory calendarFactory) {
069                    PortalRuntimePermission.checkSetBeanProperty(getClass());
070    
071                    _calendarFactory = calendarFactory;
072            }
073    
074            private static CalendarFactory _calendarFactory;
075    
076    }