001    package railo.runtime.functions.international;
002    
003    
004    import railo.commons.date.TimeZoneUtil;
005    import railo.runtime.PageContext;
006    import railo.runtime.engine.ThreadLocalPageContext;
007    import railo.runtime.exp.ExpressionException;
008    import railo.runtime.ext.function.Function;
009    import railo.runtime.functions.displayFormatting.DateTimeFormat;
010    import railo.runtime.i18n.LocaleFactory;
011    
012    /**
013     * Implements the CFML Function dateformat
014     */
015    public final class LSDateTimeFormat implements Function {
016    
017            private static final long serialVersionUID = -1677384484943178492L;
018            public static final String DEFAULT_MASK = "dd-MMM-yyyy HH:mm:ss";
019    
020            public static String call(PageContext pc , Object object) throws ExpressionException {
021                    return DateTimeFormat.invoke(pc,object, DEFAULT_MASK,pc.getLocale(),ThreadLocalPageContext.getTimeZone(pc));
022            }
023            
024            public static String call(PageContext pc , Object object, String mask) throws ExpressionException {
025                    return DateTimeFormat.invoke(pc,object, mask,pc.getLocale(),ThreadLocalPageContext.getTimeZone(pc));
026            }
027    
028            public static String call(PageContext pc , Object object, String mask,String strLocale) throws ExpressionException {
029                    return DateTimeFormat.invoke(pc,object, mask,LocaleFactory.getLocale(strLocale),ThreadLocalPageContext.getTimeZone(pc));
030            }
031    
032            public static String call(PageContext pc , Object object, String mask,String strLocale,String strTimezone) throws ExpressionException {
033                    return DateTimeFormat.invoke(
034                                    pc,object,mask, 
035                                    strLocale==null?pc.getLocale():LocaleFactory.getLocale(strLocale),
036                                    strTimezone==null?ThreadLocalPageContext.getTimeZone(pc):TimeZoneUtil.toTimeZone(strTimezone));
037            }
038            
039    }