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