Package railo.runtime.type.dt

Examples of railo.runtime.type.dt.DateTimeImpl


  }

  @Override
  public boolean setLastModified(long time) {
    PageContext pc = ThreadLocalPageContext.get();
    return provider.callbooleanRTE(pc,cfc,"setLastModified",new Object[]{new DateTimeImpl(pc, time, false)});
  }
View Full Code Here


  /**
   * @param pc
   * @return
   */
  public static DateTime call(PageContext pc ) {
    return new DateTimeImpl(pc);
  }
View Full Code Here

public class SessionStartTime implements Function {

  private static final long serialVersionUID = -3620067950402419075L;

  public static DateTime call(PageContext pc) throws PageException {
    return new DateTimeImpl(pc.sessionScope().getCreated(),false);
  }
View Full Code Here

    datepart=datepart.toLowerCase();
    long l=(long)number;
    int n=(int) l;
    char first=datepart.length()==1?datepart.charAt(0):(char)0;

    if(first=='l')       return new DateTimeImpl(pc,date.getTime()+l,false);
    else if(first=='s')   return new DateTimeImpl(pc,date.getTime()+(l*1000),false);
    else if(first=='n')    return new DateTimeImpl(pc,date.getTime()+(l*60000),false);
    else if(first=='h')    return new DateTimeImpl(pc,date.getTime()+(l*3600000),false);
   
   
    Calendar c=JREDateTimeUtil.getThreadCalendar();
    //if (c == null)c=JREDateTimeUtil.newInstance();
        //synchronized (c) {
          //c.clear();
          c.setTimeZone(tz);
          c.setTimeInMillis(date.getTime());
     
      if(datepart.equals("yyyy")) {
        c.set(Calendar.YEAR,c.get(Calendar.YEAR)+n);
      }
      else if(datepart.equals("ww")) c.add(Calendar.WEEK_OF_YEAR,n);
      else if(first=='q') c.add(Calendar.MONTH,(n*3));
      else if(first=='m') c.add(Calendar.MONTH,n);
      else if(first=='y') c.add(Calendar.DAY_OF_YEAR,n);
      else if(first=='d') c.add(Calendar.DATE,n);
      else if(first=='w') {
        int dow = c.get(Calendar.DAY_OF_WEEK);
              int offset;
              // -
              if(n < 0) {
                  if(Calendar.SUNDAY==dow) offset=2;
                  else offset=-(6-dow);
              }
              // +
              else {
                  if(Calendar.SATURDAY==dow) offset=-2;
                  else offset=dow-2;
              }
              c.add(Calendar.DAY_OF_WEEK, -offset);
             
              if(dow==Calendar.SATURDAY || dow==Calendar.SUNDAY) {
                  if(n>0) n--;
                  else if(n<0) n++;
              }
              else n+=offset;
              c.add(Calendar.DAY_OF_WEEK, (n / 5) * 7 + n % 5);
             
      }
     
      else {
        throw new ExpressionException("invalid datepart identifier ["+datepart+"] for function dateAdd");
      }
      return new DateTimeImpl(pc,c.getTimeInMillis(),false);
        //}
  }
View Full Code Here

    DeprecatedUtil.function(pc,"nowServer");
    long now = System.currentTimeMillis();
    int railo = pc.getTimeZone().getOffset(now);
    int server = TimeZone.getDefault().getOffset(now);
   
    return new DateTimeImpl(pc,now-(railo-server),false);
   
  }
View Full Code Here

  public static DateTime call(PageContext pc , String conversionType, DateTime date) throws ExpressionException {
    int offset = pc.getTimeZone().getOffset(date.getTime());
    conversionType=conversionType.toLowerCase();
   
    if(conversionType.equals("local2utc")) {
      return new DateTimeImpl(pc,date.getTime()-offset,false);
    }
    else if(conversionType.equals("utc2local")) {
      return new DateTimeImpl(pc,date.getTime()+offset,false);
    }   
    throw new ExpressionException("invalid conversion-type ["+conversionType+"] for function dateConvert");
  }
View Full Code Here

  public void sendRedirect(String location) throws IOException {
    addHeader("location",location);
  }
  @Override
  public void setDateHeader(String key, long value) {
    setHeader(key, new DateTimeImpl(value,false).castToString());
  }
View Full Code Here

      if(amf instanceof char[]) return new String((char[])amf);
      return toCFMLObject(Caster.toNativeArray(amf));
    }
    if(amf instanceof ASObject) return toCFMLObject((ASObject)amf);
    if(amf instanceof Map) return toCFMLObject((Map)amf);
    if(amf instanceof Date) return new DateTimeImpl((Date)amf);
        if(amf == null) return "";
       
    return amf;
  }
View Full Code Here

  public final void setStatus(String status) {
    this.status=status;
  }
 
  public final Date getLastmodified() {
    return new DateTimeImpl(lastModifed,false);
  }
View Full Code Here

       
        // Request
        row = req.addRow();
        req.setAt(KeyConstants._web, row, web.getLabel());
        req.setAt(KeyConstants._uri, row, getPath(_pc.getHttpServletRequest()));
        req.setAt(START_TIME, row, new DateTimeImpl(pc.getStartTime(),false));
        req.setAt(KeyConstants._timeout, row, new Double(pc.getRequestTimeout()));
       
        // Query
        queries = _pc.getActiveQueries();
        if(queries!=null) {
          for(int y=0;y<queries.length;y++){
            aq=queries[y];
            row = qry.addRow();
            qry.setAt(KeyConstants._web, row, web.getLabel());
            qry.setAt(KeyConstants._application, row, _pc.getApplicationContext().getName());
            qry.setAt(START_TIME, row, new DateTimeImpl(web,aq.startTime,true));
            qry.setAt(KeyConstants._sql, row, aq.sql);
          }
        }
       
        // Lock
        locks = _pc.getActiveLocks();
        if(locks!=null) {
          for(int y=0;y<locks.length;y++){
            al=locks[y];
            row = lck.addRow();
            lck.setAt(KeyConstants._web, row, web.getLabel());
            lck.setAt(KeyConstants._application, row, _pc.getApplicationContext().getName());
            lck.setAt(KeyConstants._name, row, al.name);
            lck.setAt(START_TIME, row, new DateTimeImpl(web,al.startTime,true));
            lck.setAt(KeyConstants._timeout, row, Caster.toDouble(al.timeoutInMillis/1000));
            lck.setAt(KeyConstants._type, row, al.type==LockManager.TYPE_EXCLUSIVE?"exclusive":"readonly");
          }
        }
      }
      openConnections+=web.getDatasourceConnectionPool().openConnections();


      // Template Cache
      Mapping[] mappings = ConfigImpl.getAllMappings(web);
      long[] tce = templateCacheElements(mappings);
      row = tc.addRow();
      tc.setAt(KeyConstants._web, row, web.getLabel());
      tc.setAt(KeyConstants._size, row, new Double(tce[1]));
      tc.setAt(ELEMENTS, row, new Double(tce[0]));
     
      // Scope Application
      getAllApplicationScopes(web,factory.getScopeContext(),app);
      getAllCFSessionScopes(web,factory.getScopeContext(),sess);
     
     
    }
   
    // Datasource
    Struct ds=new StructImpl();
    sct.setEL(KeyConstants._datasources, ds);
    ds.setEL(CACHED_QUERIES, Caster.toDouble(pc.getQueryCache().size(pc))); // there is only one cache for all contexts
    ds.setEL(OPEN_CONNECTIONS, Caster.toDouble(openConnections));
   
    // Memory
    Struct mem=new StructImpl();
    sct.setEL(KeyConstants._memory, mem);
    mem.setEL("heap", SystemUtil.getMemoryUsageAsStruct(SystemUtil.MEMORY_TYPE_HEAP));
    mem.setEL("nonheap", SystemUtil.getMemoryUsageAsStruct(SystemUtil.MEMORY_TYPE_NON_HEAP));
   
   
    // uptime
    sct.set("uptime", new DateTimeImpl(engine.uptime(),true));
   
    // now
    sct.set("now", new DateTimeImpl(pc));
   
   
    //SizeAndCount.Size size = SizeAndCount.sizeOf(pc.serverScope());
   
   
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.