DateModule.java :  » Content-Management-System » openedit » com » openedit » modules » dates » Java Open Source

Java Open Source » Content Management System » openedit 
openedit » com » openedit » modules » dates » DateModule.java
/*
 * Created on Apr 5, 2005
 */
package com.openedit.modules.dates;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.openedit.WebPageRequest;
import com.openedit.modules.BaseModule;
import com.openedit.page.PageAction;

/**
 * @author cburkey
 *
 */
public class DateModule extends BaseModule
{

  public void now(WebPageRequest inReq) throws Exception
  {
    PageAction inAction = inReq.getCurrentAction();
    
    Date date = new Date();
    inReq.putPageValue("now",date);
    
    String format = inReq.getRequestParameter("format");
    
    if ( format == null)
    {
      format = inAction.getChildValue("format");
    }
    if ( format != null)
    {
      SimpleDateFormat sformat = new SimpleDateFormat(format);
      String fdate = sformat.format(date);
      inReq.putPageValue("formatteddate",fdate);
    }
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.