Package railo.runtime.type.dt

Examples of railo.runtime.type.dt.DateTimeImpl


   * @throws PageException
   */
  public static DateTime toDateAdvanced(Object o,TimeZone timezone) throws PageException {
    if(o instanceof Date)     {
      if(o instanceof DateTime) return (DateTime)o;
      return new DateTimeImpl((Date)o);
    }
    else if(o instanceof Castable)   return ((Castable)o).castToDateTime();
    else if(o instanceof String)   {
        DateTime dt=toDateAdvanced((String)o,timezone,null);
        if(dt==null)
        throw new ExpressionException("can't cast ["+o+"] to date value");
        return dt;
    }
    else if(o instanceof Number)     return util.toDateTime(((Number)o).doubleValue());
    else if(o instanceof ObjectWrap) return toDateAdvanced(((ObjectWrap)o).getEmbededObject(),timezone);
    else if(o instanceof Calendar){
     
      return new DateTimeImpl((Calendar)o);
    }
    throw new ExpressionException("can't cast ["+Caster.toClassName(o)+"] to date value");
  }
View Full Code Here


   * @param defaultValue
   * @return Date Time Object
   */
  public static DateTime toDateAdvanced(Object o,TimeZone timeZone, DateTime defaultValue) {
    if(o instanceof DateTime)     return (DateTime)o;
    else if(o instanceof Date)     return new DateTimeImpl((Date)o);
    else if(o instanceof Castable)   {
        return ((Castable)o).castToDateTime(defaultValue);
    }
    else if(o instanceof String)   return toDateAdvanced(o.toString(),timeZone,defaultValue);
    else if(o instanceof Number)   return util.toDateTime(((Number)o).doubleValue());
    else if(o instanceof Calendar){
      return new DateTimeImpl((Calendar)o);
    }
    else if(o instanceof ObjectWrap) return toDateAdvanced(((ObjectWrap)o).getEmbededObject(defaultValue),timeZone,defaultValue);
    return defaultValue;
  }
View Full Code Here

          //try {
            pp.setErrorIndex(-1);
            pp.setIndex(0);
            d = formats[i].parse(str,pp);
            if (pp.getIndex() == 0 || d==null || pp.getIndex()<str.length()) continue
            dt= new DateTimeImpl(d.getTime(),false);
            return dt;
          //}catch (ParseException e) {}
        }
        }
        dt=toDateTime(Locale.US, str, timeZone,defaultValue, false);
View Full Code Here

              d = df[i].parse(str,pp);
              if (pp.getIndex() == 0 || d==null || pp.getIndex()<str.length()) continue
       
              synchronized(c) {
                optimzeDate(c,tz,d);
                return new DateTimeImpl(c.getTime());
              }
              //}catch (ParseException e) {}
          }
          // date
          df=FormatUtil.getDateFormats(locale,tz,false);//dfc[FORMATS_DATE];
          //print.e(locale.getDisplayName(Locale.ENGLISH));
        for(int i=0;i<df.length;i++) {
          //print.e(df[i].format(new Date()));
          pp.setErrorIndex(-1);
        pp.setIndex(0);
        //try {
              df[i].setTimeZone(tz);
        d=df[i].parse(str,pp);
              if (pp.getIndex() == 0 || d==null || pp.getIndex()<str.length()) continue
             
        synchronized(c) {
                optimzeDate(c,tz,d);
                return new DateTimeImpl(c.getTime());
              }
        //}catch (ParseException e) {}
          }
       
          // time
          df=FormatUtil.getTimeFormats(locale,tz,false);//dfc[FORMATS_TIME];
          //print.e(locale.getDisplayName(Locale.ENGLISH));
        for(int i=0;i<df.length;i++) {
            //print.e(df[i].format(new Date()));
          pp.setErrorIndex(-1);
        pp.setIndex(0);
        //try {
              df[i].setTimeZone(tz);
              d=df[i].parse(str,pp);
              if (pp.getIndex() == 0 || d==null || pp.getIndex()<str.length()) continue
              synchronized(c) {
                c.setTimeZone(tz);
                c.setTime(d);
                c.set(Calendar.YEAR,1899);
                  c.set(Calendar.MONTH,11);
                  c.set(Calendar.DAY_OF_MONTH,30);
                c.setTimeZone(tz);
              }
                return new DateTimeImpl(c.getTime());
              //}catch (ParseException e) {}
          }
        //}
        if(useCommomDateParserAsWell)return DateCaster.toDateSimple(str, false,true, tz, defaultValue);
        return defaultValue;
View Full Code Here

   * @return coverted Date Time Object
   * @throws PageException
   */
  public static DateTime toDateSimple(Object o, boolean alsoNumbers,boolean alsoMonthString, TimeZone timeZone) throws PageException {
    if(o instanceof DateTime)     return (DateTime)o;
    else if(o instanceof Date)     return new DateTimeImpl((Date)o);
    else if(o instanceof Castable)   return ((Castable)o).castToDateTime();
    else if(o instanceof String)   return toDateSimple(o.toString(),alsoNumbers,alsoMonthString, timeZone);
    else if(o instanceof Number)     return util.toDateTime(((Number)o).doubleValue());
    else if(o instanceof Calendar)     return new DateTimeImpl((Calendar)o);
    else if(o instanceof ObjectWrap) return toDateSimple(((ObjectWrap)o).getEmbededObject(),alsoNumbers,alsoMonthString,timeZone);
    else if(o instanceof Calendar){
      return new DateTimeImpl((Calendar)o);
    }
   
    if(o instanceof Component)
      throw new ExpressionException("can't cast component ["+((Component)o).getAbsName()+"] to date value");
   
View Full Code Here

    throw new ExpressionException("can't cast ["+Caster.toTypeName(o)+"] to date value");
  }
 
  public static DateTime toDateSimple(Object o, boolean alsoNumbers,boolean alsoMonthString, TimeZone timeZone, DateTime defaultValue) {
    if(o instanceof DateTime)     return (DateTime)o;
    else if(o instanceof Date)     return new DateTimeImpl((Date)o);
    else if(o instanceof Castable)   return ((Castable)o).castToDateTime(defaultValue);
    else if(o instanceof String)   return toDateSimple(o.toString(),alsoNumbers,alsoMonthString, timeZone,defaultValue);
    else if(o instanceof Number)     return util.toDateTime(((Number)o).doubleValue());
    else if(o instanceof Calendar)     return new DateTimeImpl((Calendar)o);
    else if(o instanceof ObjectWrap) {
      Object eo = ((ObjectWrap)o).getEmbededObject(NULL);
      if(eo==NULL) return defaultValue;
      return toDateSimple(eo,alsoNumbers,alsoMonthString,timeZone,defaultValue);
    }
    else if(o instanceof Calendar){
      return new DateTimeImpl((Calendar)o);
    }
    return defaultValue;
  }
View Full Code Here

        return _toDateAdvanced(o, alsoNumbers, timeZone, defaultValue, true);
   }
  
   private static DateTime _toDateAdvanced(Object o,boolean alsoNumbers, TimeZone timeZone, DateTime defaultValue, boolean advanced) {
        if(o instanceof DateTime)       return (DateTime)o;
        else if(o instanceof Date)      return new DateTimeImpl((Date)o);
        else if(o instanceof Castable)  {
            return ((Castable)o).castToDateTime(defaultValue);
        }
        else if(o instanceof String)    {
          if(advanced)return toDateAdvanced(o.toString(),alsoNumbers, timeZone,defaultValue);
          return toDateSimple(o.toString(),alsoNumbers,true, timeZone,defaultValue);
        }
        else if(alsoNumbers && o instanceof Number)     return util.toDateTime(((Number)o).doubleValue());
        else if(o instanceof ObjectWrap) {
          return _toDateAdvanced(((ObjectWrap)o).getEmbededObject(defaultValue),alsoNumbers,timeZone,defaultValue,advanced);
        }
        else if(o instanceof Calendar){
      return new DateTimeImpl((Calendar)o);
    }
    return defaultValue;
    }
View Full Code Here

      return new int[]{util.toYear(first), second, 1};
    }
    return null;
  }
  private static int year(TimeZone tz) {
    return util.getYear(ThreadLocalPageContext.getTimeZone(tz),new DateTimeImpl());
  }
View Full Code Here

  if(ds.isAfterLast()) {
    long time= util.toTime(TimeZoneConstants.UTC, years, months, days, hours, minutes, seconds, milliSeconds, 0);
     
    if(isPlus)time-=offset;
          else time+=offset;
    return new DateTimeImpl(time,false);
  }
  return defaultValue;
    }
View Full Code Here

  }
 
    @Override
    public SearchCollection _createCollection(String name, Resource path, String language) throws SearchException {
      //SearchUtil.getAnalyzer(language);
        return new LuceneSearchCollection(this,name,path,language,new DateTimeImpl(),new DateTimeImpl());
    }
View Full Code Here

TOP

Related Classes of railo.runtime.type.dt.DateTimeImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.