001 /** 002 * Implements the Cold Fusion Function lsparsedatetime 003 */ 004 package railo.runtime.functions.international; 005 006 import java.util.Date; 007 import java.util.Locale; 008 import java.util.TimeZone; 009 010 import railo.commons.date.TimeZoneUtil; 011 import railo.runtime.PageContext; 012 import railo.runtime.exp.PageException; 013 import railo.runtime.ext.function.Function; 014 import railo.runtime.i18n.LocaleFactory; 015 import railo.runtime.op.Caster; 016 017 public final class LSParseDateTime implements Function { 018 019 private static final long serialVersionUID = 7808039073301229473L; 020 021 public static railo.runtime.type.dt.DateTime call(PageContext pc , Object oDate) throws PageException { 022 return _call(pc, oDate, pc.getLocale(),pc.getTimeZone()); 023 } 024 025 public static railo.runtime.type.dt.DateTime call(PageContext pc , Object oDate,String strLocale) throws PageException { 026 return _call(pc, oDate, LocaleFactory.getLocale(strLocale),pc.getTimeZone()); 027 } 028 029 public static railo.runtime.type.dt.DateTime call(PageContext pc , Object oDate,String strLocale,String strTimezone) throws PageException { 030 return _call(pc, oDate, 031 strLocale==null?pc.getLocale():LocaleFactory.getLocale(strLocale), 032 strTimezone==null?pc.getTimeZone():TimeZoneUtil.toTimeZone(strTimezone)); 033 } 034 035 private static railo.runtime.type.dt.DateTime _call(PageContext pc , Object oDate,Locale locale,TimeZone tz) throws PageException { 036 if(oDate instanceof Date) return Caster.toDate(oDate, tz); 037 return Caster.toDateTime(locale,Caster.toString(oDate),tz,locale.equals(Locale.US)); 038 //return Caster.toDateTime(locale,Caster.toString(oDate),tz,false); 039 } 040 }