Wednesday, November 30, 2011

Version 1.1.3 (stable) of the Time2 Library brings a new utility

A new version of the Time2 Library is available at http://time2.sourceforge.net/ and http://agent.ch/timeseries/t2/.

This new release comes with a small utility for scanning dates and times in arbitrary formats. Here is a quick usage example:

String pattern = 
  "\\S+ (\\S+) (\\d+) (\\d\\d):(\\d\\d):(\\d\\d) \S+ (\\d\\d\\d\\d)";
int[] groups = {6, 1, 2, 3, 4, 5};
String[] months = 
     {"Jan", "Feb", "Mar", "Apr", "May", "Jun", 
      "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
DateTimeScanner scanner = new DateTimeScanner(pattern, groups);
scanner.setMonths(months);
scanner.setDomain(DateTime.DOMAIN);
TimeIndex time = scanner.scan("Wed Nov 30 12:29:23 CET 2010");
assertEquals("2010-11-30 12:29:23", time.toString());

No comments:

Post a Comment