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());