001 /** 002 * Implements the Cold Fusion Function dateconvert 003 */ 004 package railo.runtime.functions.dateTime; 005 006 import railo.runtime.PageContext; 007 import railo.runtime.exp.ExpressionException; 008 import railo.runtime.ext.function.Function; 009 import railo.runtime.type.dt.DateTime; 010 import railo.runtime.type.dt.DateTimeImpl; 011 012 public final class DateConvert implements Function { 013 public static DateTime call(PageContext pc , String conversionType, DateTime date) throws ExpressionException { 014 int offset = pc.getTimeZone().getOffset(date.getTime()); 015 conversionType=conversionType.toLowerCase(); 016 017 if(conversionType.equals("local2utc")) { 018 return new DateTimeImpl(pc,date.getTime()-offset,false); 019 } 020 else if(conversionType.equals("utc2local")) { 021 return new DateTimeImpl(pc,date.getTime()+offset,false); 022 } 023 throw new ExpressionException("invalid conversion-type ["+conversionType+"] for function dateConvert"); 024 } 025 }