import ws.*;

// Example of using WUtil class on Passage Server

public class api_WUtil
{
  public WTableList Request(WServer oServer, WParamList oParamList)
  { 
    int i;
    String     sz;
    WTableList oTableList;
    WUtil      oUtil;
    WDateTime  oDateTime;
    double     d;

    oTableList = oServer.newTableList();
    oUtil      = new WUtil();

    // Amount
    sz = oUtil.checkAmount("123");                 // returns 123.00
    sz = oUtil.checkAmount("123 67");              // returns 123.00
    sz = oUtil.checkAmount("123.45 67");           // returns 123.45
    sz = oUtil.checkAmount("abc");                 // returns 0.00

    sz = oUtil.checkAmountNoCent("123.45");        // returns 123
    sz = oUtil.checkAmountNoCent("123.45 678");    // returns 123

    sz = oUtil.checkAmountComma("1234.56");        // returns 1,234.56

    sz = oUtil.checkAmountCommaNoCent("1234.12");  // returns 1,234
    sz = oUtil.checkAmountCommaNoCent("1234.67");  // returns 1,235

     d = oUtil.getAmount("123.456");               // returns 123.46
    sz = oUtil.setAmount(d);                       // returns 123.46


    // Double
    sz = oUtil.checkDouble("123.4567");            // returns 123.4567
    sz = oUtil.checkDouble("123.4567 89");         // returns 123.4567
    sz = oUtil.checkDouble("abc");                 // returns 0
    sz = oUtil.checkDouble("123");                 // returns 123
    
     d = oUtil.getDouble("123.456");               // returns 123.456
    sz = oUtil.setDouble(d,2);                     // returns 123.46
    sz = oUtil.setDouble(d,3);                     // returns 123.456


    // Int
    sz = oUtil.checkInt("123.4567");               // returns 123
    sz = oUtil.checkInt("123 56");                 // returns 123
    sz = oUtil.checkInt("123abc");                 // returns 123

     i = oUtil.getInt("123.456");                  // returns 123
    sz = oUtil.setInt(i);                          // returns 123


    // DateTime
    // date and time come from database or manual entry

    oDateTime = oUtil.getDateTime("22/03/2007 17:55:24");   
    sz = oDateTime.getDate();                      // returns 22/03/2007
    sz = oDateTime.getTime();                      // returns 17:55

    oDateTime = oUtil.getDateTime("22/03/2007");   
    sz = oDateTime.getDate();                      // returns 22/03/2007

    oDateTime = oUtil.getDateTime("17:55:24");   
    sz = oDateTime.getTime();                      // returns 17:55

    oDateTime = oUtil.getDateTime("");   
    sz = oDateTime.getDate();                      // returns 01/01/1800
    sz = oDateTime.getTime();                      // returns 00:00

    oDateTime = oUtil.getDateTime("22/03/2007 abcdefgh");   
    sz = oDateTime.getDate();                      // 22/03/2007
    sz = oDateTime.getTime();                      // 00:00

    oDateTime = oUtil.getLocalDateTime();   
    sz = oDateTime.getDate();                      // returns 23/03/2007
    sz = oDateTime.getTime();                      // returns 17:55

    i = oUtil.checkDay(10,3);                      // returns 10
    i = oUtil.checkDay(32,3);                      // returns 0

    sz = oUtil.getMonth(3);                        // Mar
    sz = oUtil.getMonth(13);                       // 


    // String
    sz = oUtil.checkStr("abc");                    // returns abc
    sz = oUtil.checkStr("abc'123'xyz");            // returns abc''123''xyz

    sz = oUtil.checkStrHtml("abc 123");            // returns abc<br>xyz

    return oTableList; 
  }
}