public static Time toTime ( TimeZone timeZone , Object o ) throws PageException { if ( o instanceof Time ) return ( Time ) o ; else if ( o instanceof Date ) return new TimeImpl ( ( Date ) o ) ; else if ( o instanceof Castable ) return new TimeImpl ( ( ( Castable ) o ) . castToDateTime ( ) ) ; else if ( o instanceof String ) { Time dt = toTime ( timeZone , o . toString ( ) , null ) ; if ( dt == null ) throw new ExpressionException ( "can't cast [" + o + "] to time value" ) ; return dt ; } else if ( o instanceof ObjectWrap ) return toTime ( timeZone , ( ( ObjectWrap ) o ) . getEmbededObject ( ) ) ; else if ( o instanceof Calendar ) { // TODO check timezone offset return new TimeImpl ( ( ( Calendar ) o ) . getTimeInMillis ( ) , false ) ; } throw new ExpressionException ( "can't cast [" + Caster . toClassName ( o ) + "] to time value" ) ; }
converts a Object to a Time Object returns null if invalid string