@Test
  public void testPattern1() {
    // Timestamp pattern matching expects fractional seconds length to match
    // the number of 'S' in the pattern. So if you want to match .1, .12, .123,
    // you need 3 different patterns with .S, .SS, .SSS
    // ISO-8601 timestamps
    final String[] patterns = {"yyyy-MM-dd'T'HH:mm:ss",
        "yyyy-MM-dd'T'HH:mm:ss.S", "yyyy-MM-dd'T'HH:mm:ss.SS",
        "yyyy-MM-dd'T'HH:mm:ss.SSS", "yyyy-MM-dd'T'HH:mm:ss.SSSS"};

    final TimestampParser tsp = new TimestampParser(patterns);

    Assert.assertEquals(Timestamp.valueOf("1945-12-31 23:59:59.0"),
        tsp.parseTimestamp("1945-12-31T23:59:59.0"));

    Assert.assertEquals(Timestamp.valueOf("2001-01-01 00:00:00.100"),
        tsp.parseTimestamp("2001-01-01T00:00:00.100"));

    Assert.assertEquals(Timestamp.valueOf("2001-01-01 00:00:00.001"),
        tsp.parseTimestamp("2001-01-01T00:00:00.001"));

    Assert.assertEquals(Timestamp.valueOf("1945-12-31T23:59:59.123"),
        tsp.parseTimestamp("1945-12-31T23:59:59.123"));

    Assert.assertEquals(Timestamp.valueOf("1945-12-31T23:59:59.123"),
        tsp.parseTimestamp("1945-12-31T23:59:59.1234"));

    Assert.assertEquals(Timestamp.valueOf("1970-01-01 00:00:00"),
        tsp.parseTimestamp("1970-01-01T00:00:00"));

    /** Default timestamp format still works? */

    Assert.assertEquals(Timestamp.valueOf("1945-12-31 23:59:59.1234"),
        tsp.parseTimestamp("1945-12-31 23:59:59.1234"));

    Assert.assertEquals(Timestamp.valueOf("1945-12-31 23:59:59.12345"),
        tsp.parseTimestamp("1945-12-31T23:59:59.12345"));
  }
No timestamp patterns, should default to normal timestamp format.

@see Timestamp#valueOf(String)
common/src/test/org/apache/hive/common/util/TestTimestampParser.java