TodaysDate (Java)

    TodaysDate (Java)

    .

    TodaysDate is a small Java handler that returns a text string of the form “Thursday 18 June 1998”, as requested by a client.

    package client.someone.handler.misc;

    import java.util.Hashtable;

    import java.util.Vector;

    import organic.servlet.broker.*;

    import organic.client.feld.Stuff;

    import java.util.Calendar ;

    import java.text.SimpleDateFormat ;

    import java.text.FieldPosition ;

    // Returns “Thursday, 18th June 1998”

    public class TodaysDate implements HandlerInterface {

    public Object handleToken(String tokenName,

    Hashtable args,

    Request request)

    throws HandlerException

    {

    try {

    String[] thArray = new String[] {

    “th”, “st”,”nd”,”rd”,”th”,”th”,”th”,”th”,”th”,”th”,”th”,

    “th”,”th”,”th”,”th”,”th”,”th”,”th”,”th”,”th”,”th”,

    “st”,”nd”,”rd”,”th”,”th”,”th”,”th”,”th”,”th”,”th”,”st” };

    Calendar c = Calendar.getInstance() ;

    SimpleDateFormat f = new SimpleDateFormat( “EEEE, MMMM dd” ) ;

    SimpleDateFormat g = new SimpleDateFormat( “yyyy” ) ;

    SimpleDateFormat h = new SimpleDateFormat( “dd” ) ;

    int dim = (new Integer(h.format( c.getTime() ))).intValue() ;

    return f.format( c.getTime()) + thArray[dim] + ” ” + g.format( c.getTime()) ;

    } catch (Exception e) { throw new HandlerException(e); }

    }

    }

    This page

    is

    1993-2006 by ,

    via the Creative Commons License. Questions and comments? Send

    to the Geek Times Webmaster. (Domain and web content hosting at .)

    Leave a Reply

    Your email address will not be published.

    TodaysDate (Java)

    TodaysDate (Java)

    .

    TodaysDate is a small Java handler that returns a text string of the form “Thursday 18 June 1998”, as requested by a client.

    package client.someone.handler.misc;

    import java.util.Hashtable;

    import java.util.Vector;

    import organic.servlet.broker.*;

    import organic.client.feld.Stuff;

    import java.util.Calendar ;

    import java.text.SimpleDateFormat ;

    import java.text.FieldPosition ;

    // Returns “Thursday, 18th June 1998”

    public class TodaysDate implements HandlerInterface {

    public Object handleToken(String tokenName,

    Hashtable args,

    Request request)

    throws HandlerException

    {

    try {

    String[] thArray = new String[] {

    “th”, “st”,”nd”,”rd”,”th”,”th”,”th”,”th”,”th”,”th”,”th”,

    “th”,”th”,”th”,”th”,”th”,”th”,”th”,”th”,”th”,”th”,

    “st”,”nd”,”rd”,”th”,”th”,”th”,”th”,”th”,”th”,”th”,”st” };

    Calendar c = Calendar.getInstance() ;

    SimpleDateFormat f = new SimpleDateFormat( “EEEE, MMMM dd” ) ;

    SimpleDateFormat g = new SimpleDateFormat( “yyyy” ) ;

    SimpleDateFormat h = new SimpleDateFormat( “dd” ) ;

    int dim = (new Integer(h.format( c.getTime() ))).intValue() ;

    return f.format( c.getTime()) + thArray[dim] + ” ” + g.format( c.getTime()) ;

    } catch (Exception e) { throw new HandlerException(e); }

    }

    }

    This page

    is

    1993-2006 by ,

    via the Creative Commons License. Questions and comments? Send

    to the Geek Times Webmaster. (Domain and web content hosting at .)

    Leave a Reply

    Your email address will not be published.