Time


The Time package has four classes: DateFormatUtils, DateUtils, FastDateFormat, and StopWatch. Both DateFormatUtils and FastDateFormat serve to make it easier to render dates into strings. FastDateFormat is a quick, thread-safe implementation of a date and time formatter. DateFormatUtils includes several FastDateFormat objects, preconfigured for different uses, including different ISO8601 formats as well as an SMTP format.

The StopWatch class allows you to perform timings much like a stopwatchit allows you to start a timer, perform a split, stop, reset, and so on. Note that the StopWatch class is really only a holder for time values from System.currentTimeMillis()there is no notion of a scheduler or execution thread. Interestingly, the code:

 StopWatch testWatch = new StopWatch(); try {      testWatch.start();      Thread.sleep(1000);      testWatch.stop();      System.out.println(testWatch.getTime());    } catch (Exception e)  { e.printStackTrace(); } 

. . . returns a value of 1001.



    Apache Jakarta Commons(c) Reusable Java Components
    Real World Web Services
    ISBN: N/A
    EAN: 2147483647
    Year: 2006
    Pages: 137
    Authors: Will Iverson

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net