Package edu.uams.dbmi.util.iso8601

Examples of edu.uams.dbmi.util.iso8601.Iso8601TimeFormatter


   
  }

  public void testYearMonthDayString(Iso8601DateParser parser, String s, int yr,
      int mo, int da) throws Iso8601DateParseException {
    Iso8601Date d1 = parser.parse(s);
    assertNotNull(d1);
    assertTrue(d1.isDay());
    assertEquals(d1.getYear(), yr);
    assertEquals(d1.getCentury(), yr/100);
    assertEquals(d1.getMonth(), mo);
    assertEquals(d1.getDayOfMonth(), da);
    assertFalse(d1.isMonth());
    assertFalse(d1.isWeek());
    assertFalse(d1.isYear());
    assertFalse(d1.isCentury());
    GregorianCalendar cal = d1.getCalendarForDay();
    assertNotNull(cal);
    if (yr > 0) {
      assertEquals(cal.get(Calendar.YEAR), yr);
      assertEquals(cal.get(Calendar.ERA), GregorianCalendar.AD);
    } else {
View Full Code Here


  }
 
  public void testYearMonthDaySet(Iso8601Date d, String yrTxt, String moTxt,
      String daTxt) {
    FormatOptions fo = new FormatOptions();
    testYearMonthDay(d, DateConfiguration.YEAR_MONTH_DAY, fo, yrTxt,
        moTxt, daTxt);
    testYearMonthDay(d, DateConfiguration.YEAR_MONTH, fo, yrTxt,
        moTxt, daTxt);
    testYearMonthDay(d, DateConfiguration.YEAR, fo, yrTxt,
View Full Code Here

       
  }
 
  public void testYearWeekDaySet(Iso8601Date d, String wkCalYrTxt, String weTxt,
      String daTxt, String yrTxt) {
    FormatOptions fo = new FormatOptions();
    testYearWeekDay(d, DateConfiguration.YEAR_WEEK_DAY, fo, wkCalYrTxt,
        weTxt, daTxt, yrTxt);
    testYearWeekDay(d, DateConfiguration.YEAR_WEEK, fo, wkCalYrTxt,
        weTxt, daTxt, yrTxt);
    testYearWeekDay(d, DateConfiguration.YEAR, fo, wkCalYrTxt,
View Full Code Here

   
  }
 
  public void testYearDayOfYearSet(Iso8601Date d, String yrTxt,
      String dyTxt) {
    FormatOptions fo = new FormatOptions();
    testYearDayOfYear(d, DateConfiguration.YEAR_DAY_OF_YEAR, fo, yrTxt,
        dyTxt);
    testYearDayOfYear(d, DateConfiguration.YEAR, fo, yrTxt,
        dyTxt);
    testYearDayOfYear(d, DateConfiguration.CENTURY, fo, yrTxt,
View Full Code Here

public class Iso8601DateParserTest extends TestCase {

  @Test
  public void testWeekFormatParse() {
    Iso8601DateParser parser = new Iso8601DateParser();
   
    String s1 = "2010-W01-1";
    try {
      Iso8601Date d1 = parser.parse(s1);
      assertNotNull(d1);
      assertTrue(d1.isDay());
      assertEquals(d1.getYear(), 2010);
      assertEquals(d1.getWeekOfYear(), 1);
      assertEquals(d1.getDayOfWeek(), 1);
    } catch (Iso8601DateParseException e) {
      fail();
      e.printStackTrace();
    }
   
    String s2 = "2010-W01";
    try {
      Iso8601Date d2 = parser.parse(s2);
      assertNotNull(d2);
      assertFalse(d2.isDay());
      assertTrue(d2.isWeek());
      assertEquals(d2.getYear(), 2010);
      assertEquals(d2.getWeekOfYear(), 1);
    } catch (Iso8601DateParseException e) {
      e.printStackTrace();
      fail();
    }
   
    String s3 = "2010W01";
    try {
      Iso8601Date d3 = parser.parse(s3);
      assertNotNull(d3);
      assertFalse(d3.isDay());
      assertTrue(d3.isWeek());
      assertEquals(d3.getYear(), 2010);
      assertEquals(d3.getWeekOfYear(), 1);
    } catch (Iso8601DateParseException e) {
      e.printStackTrace();
      fail();
    }
   
    String s4 = "2010W011";
    try {
      Iso8601Date d4 = parser.parse(s4);
      assertNotNull(d4);
      assertTrue(d4.isDay());
      assertEquals(d4.getYear(), 2010);
      assertEquals(d4.getWeekOfYear(), 1);
      assertEquals(d4.getDayOfWeek(), 1);
    } catch (Iso8601DateParseException e) {
      e.printStackTrace();
      fail();
    }
   
    String s5 = "2010011";
    try {
      Iso8601Date d5 = parser.parse(s5);
      assertNotNull(d5);
      assertTrue(d5.isDay());
      assertEquals(d5.getYear(), 2010);
      assertEquals(d5.getDayOfYear(), 11);
    } catch (Iso8601DateParseException e) {
      e.printStackTrace();
      fail();
    }
   
    String s6 = "2010W1";
    boolean correctError = false;
    try {
      parser.parse(s6);
    } catch (Iso8601DateParseException e) {
      System.err.println(e.getMessage());
      correctError = true;
    } catch (NumberFormatException e1) {
      e1.printStackTrace();
      fail();
    }
    assertTrue(correctError);
   
    String s7 = "201001";
    try {
      Iso8601Date d7 = parser.parse(s7);
      assertNotNull(d7);
      assertTrue(d7.isMonth());
      assertEquals(d7.getYear(), 2010);
      assertEquals(d7.getMonth(), 1);
    } catch (Iso8601DateParseException e) {
      e.printStackTrace();
      fail();
    }
   
    String s8 = "2010-W011";
    boolean correctError2 = false;
    try {
      parser.parse(s8);
    } catch (Iso8601DateParseException e) {
      correctError2 = true;
      System.err.println(e.getMessage());
    } catch (NumberFormatException nfe) {
      nfe.printStackTrace();
View Full Code Here

    assertTrue(correctError2);
  }
 
  @Test
  public void testCenturyParse() {
    Iso8601DateParser parser = new Iso8601DateParser();
   
    String c1 = "20";
    try {
      testCenturyString(parser, c1, 20);
    } catch (Iso8601DateParseException e1) {
      e1.printStackTrace();
      fail();
    }
   
    String c2 = "+15";
    try {
      testCenturyString(parser, c2, 15);
    } catch (Iso8601DateParseException e1) {
      e1.printStackTrace();
      fail();
    }

   
    String c3 = "-05";
    try {
      testCenturyString(parser, c3, -5);
    } catch (Iso8601DateParseException e1) {
      e1.printStackTrace();
      fail();
    }
   
    String c4 = "00";
    try {
      testCenturyString(parser, c4, 0);
    } catch (Iso8601DateParseException e1) {
      e1.printStackTrace();
      fail();
    }
   
    String c5 = "5";
    boolean error1 = false;
    try {
      parser.parse(c5);
    } catch (Iso8601DateParseException e) {
      error1 = true;
      System.err.println(e.getMessage());
    }
    assertTrue(error1);
   
    String c6 = "123";
    boolean error2 = false;
    try {
      parser.parse(c6);
    } catch (Iso8601DateParseException e) {
      error2 = true;
      System.err.println(e.getMessage());
    }
    assertTrue(error2);
View Full Code Here

      }
  }
 
  @Test
  public void testYearParse() {
    Iso8601DateParser parser = new Iso8601DateParser();
   
    String s1 = "2011";
    try {
      testYearString(parser, s1, 2011);
    } catch (Iso8601DateParseException e7) {
View Full Code Here

    }
  }
 
  @Test
  public void testYearMonthParse() {
    Iso8601DateParser parser = new Iso8601DateParser();
   
    String s1 = "1582-08";
    try {
      testYearMonthString(parser, s1, 1582, 8);
    } catch (Iso8601DateParseException e) {
View Full Code Here

    assertEquals(cal.get(Calendar.MONTH), mo-1);
  }
 
  @Test
  public void testYearMonthDayParse() {
    Iso8601DateParser parser = new Iso8601DateParser();
   
    String s1 = "+0000-01-01";
    try {
      testYearMonthDayString(parser, s1, 0, 1, 1);
    } catch (Iso8601DateParseException e) {
View Full Code Here

    assertEquals(cal.get(Calendar.DAY_OF_MONTH), da);
  }
 
  @Test
  public void testYearDayParse() {
    Iso8601DateParser parser = new Iso8601DateParser();
   
    String s1 = "2011233";
    try {
      testYearDayString(parser, s1, 2011, 233);
    } catch (Iso8601DateParseException e) {
View Full Code Here

TOP

Related Classes of edu.uams.dbmi.util.iso8601.Iso8601TimeFormatter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.