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.text.Format;
020    
021    import java.util.Locale;
022    import java.util.TimeZone;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     */
027    public class FastDateFormatFactoryUtil {
028    
029            public static Format getDate(int style, Locale locale, TimeZone timeZone) {
030                    return getFastDateFormatFactory().getDate(style, locale, timeZone);
031            }
032    
033            public static Format getDate(Locale locale) {
034                    return getFastDateFormatFactory().getDate(locale);
035            }
036    
037            public static Format getDate(Locale locale, TimeZone timeZone) {
038                    return getFastDateFormatFactory().getDate(locale, timeZone);
039            }
040    
041            public static Format getDate(TimeZone timeZone) {
042                    return getFastDateFormatFactory().getDate(timeZone);
043            }
044    
045            public static Format getDateTime(
046                    int dateStyle, int timeStyle, Locale locale, TimeZone timeZone) {
047    
048                    return getFastDateFormatFactory().getDateTime(
049                            dateStyle, timeStyle, locale, timeZone);
050            }
051    
052            public static Format getDateTime(Locale locale) {
053                    return getFastDateFormatFactory().getDateTime(locale);
054            }
055    
056            public static Format getDateTime(Locale locale, TimeZone timeZone) {
057                    return getFastDateFormatFactory().getDateTime(locale, timeZone);
058            }
059    
060            public static Format getDateTime(TimeZone timeZone) {
061                    return getFastDateFormatFactory().getDateTime(timeZone);
062            }
063    
064            public static FastDateFormatFactory getFastDateFormatFactory() {
065                    PortalRuntimePermission.checkGetBeanProperty(
066                            FastDateFormatFactoryUtil.class);
067    
068                    return _fastDateFormatFactory;
069            }
070    
071            public static Format getSimpleDateFormat(String pattern) {
072                    return getFastDateFormatFactory().getSimpleDateFormat(pattern);
073            }
074    
075            public static Format getSimpleDateFormat(String pattern, Locale locale) {
076                    return getFastDateFormatFactory().getSimpleDateFormat(pattern, locale);
077            }
078    
079            public static Format getSimpleDateFormat(
080                    String pattern, Locale locale, TimeZone timeZone) {
081    
082                    return getFastDateFormatFactory().getSimpleDateFormat(
083                            pattern, locale, timeZone);
084            }
085    
086            public static Format getSimpleDateFormat(
087                    String pattern, TimeZone timeZone) {
088    
089                    return getFastDateFormatFactory().getSimpleDateFormat(
090                            pattern, timeZone);
091            }
092    
093            public static Format getTime(int style, Locale locale, TimeZone timeZone) {
094                    return getFastDateFormatFactory().getTime(style, locale, timeZone);
095            }
096    
097            public static Format getTime(Locale locale) {
098                    return getFastDateFormatFactory().getTime(locale);
099            }
100    
101            public static Format getTime(Locale locale, TimeZone timeZone) {
102                    return getFastDateFormatFactory().getTime(locale, timeZone);
103            }
104    
105            public static Format getTime(TimeZone timeZone) {
106                    return getFastDateFormatFactory().getTime(timeZone);
107            }
108    
109            public void setFastDateFormatFactory(
110                    FastDateFormatFactory fastDateFormatFactory) {
111    
112                    PortalRuntimePermission.checkSetBeanProperty(getClass());
113    
114                    _fastDateFormatFactory = fastDateFormatFactory;
115            }
116    
117            private static FastDateFormatFactory _fastDateFormatFactory;
118    
119    }