Examples of ISO8601DateFormat


Examples of com.fasterxml.jackson.databind.util.ISO8601DateFormat

    {
        Calendar cal = new GregorianCalendar(2007, 8 - 1, 13, 19, 51, 23);
        cal.setTimeZone(TimeZone.getTimeZone("GMT"));
        cal.set(Calendar.MILLISECOND, 0);
        date = cal.getTime();
        df = new ISO8601DateFormat();
    }
View Full Code Here

Examples of com.fasterxml.jackson.databind.util.ISO8601DateFormat

public class JSONSerializerDeprecatedTest extends TestCase {

    public void test_() throws Exception {
        JSONSerializer ser = new JSONSerializer(new JSONSerializerMap());
       
        ser.setDateFormat(new ISO8601DateFormat());
        Assert.assertEquals(null, ser.getDateFormatPattern());
       
        ser.close();
    }
View Full Code Here

Examples of com.fasterxml.jackson.databind.util.ISO8601DateFormat

  /**
   * Builde default Jackson ObjectMapper
   */
  public static ObjectMapper build() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.setDateFormat(new ISO8601DateFormat());
    return mapper;
  }
View Full Code Here

Examples of com.fasterxml.jackson.databind.util.ISO8601DateFormat

     * {@inheritDoc}
     */
    @Override
    public Date deserialize(final JsonParser parser,
                            final DeserializationContext context) throws IOException {
        final DateFormat format = new ISO8601DateFormat();
        try {
            return format.parse(parser.getText());
        } catch (final ParseException pe) {
            throw new IOException(pe);
        }
    }
View Full Code Here

Examples of com.skaringa.util.ISO8601DateFormat

   * @param xmlType may be 'xsd:dateTime' or 'xsd:date'
   * @return a <code>DateFormat</code> value
   */
  private DateFormat newFormatter(String xmlType) {
    if ("xsd:date".equals(xmlType)) {
      return new ISO8601DateFormat(TimeZone.getDefault());
    }
    return new ISO8601DateTimeFormat(TimeZone.getDefault());
  }
View Full Code Here

Examples of com.skaringa.util.ISO8601DateFormat

   * Test the formatting
   */
  public void testFormat() {
    Calendar cal = new GregorianCalendar(1962, 0, 19);
    cal.setTimeZone(TimeZone.getTimeZone("GMT+01"));
    ISO8601DateFormat formatter = new ISO8601DateFormat();
    String res = formatter.format(cal.getTime());

    assertEquals(
      "ISO 8601 date formatter produces wrong output",
      "1962-01-19",
      res);
View Full Code Here

Examples of com.skaringa.util.ISO8601DateFormat

    Collection calendars = new ArrayList();
    calendars.add(new GregorianCalendar(1962, 0, 19));
    calendars.add(new GregorianCalendar(20, 1, 1));
    calendars.add(new GregorianCalendar(2003, 10, 1));

    ISO8601DateFormat formatter = new ISO8601DateFormat();

    Iterator it = calendars.iterator();
    while (it.hasNext()) {
      Calendar cal = (Calendar) it.next();
      Date date = cal.getTime();

      String serial = formatter.format(date);

      ParsePosition pos = new ParsePosition(0);
      Date parsedDate = formatter.parse(serial, pos);
      assertNotNull(
        "Parsing of " + serial + " failed at position " + pos.getIndex(),
        parsedDate);
      assertEquals(
        "ISO 8601 date parser produces wrong result",
View Full Code Here

Examples of com.skaringa.util.ISO8601DateFormat

   * @throws Exception If the test failes.
   */
  public void testParse() throws Exception {
    Calendar cal = Calendar.getInstance();

    ISO8601DateFormat formatter = new ISO8601DateFormat();

    // east
    Date parsedDate = formatter.parse("1970-01-01+01:00");
    cal.setTime(parsedDate);
    cal.setTimeZone(TimeZone.getTimeZone("GMT+01"));
    assertEquals(1970, cal.get(Calendar.YEAR));
    assertEquals(Calendar.JANUARY, cal.get(Calendar.MONTH));
    assertEquals(1, cal.get(Calendar.DAY_OF_MONTH));

    // west
    parsedDate = formatter.parse("1969-12-31-05:00");
    cal.setTime(parsedDate);
    cal.setTimeZone(TimeZone.getTimeZone("GMT-05"));
    assertEquals(1969, cal.get(Calendar.YEAR));
    assertEquals(Calendar.DECEMBER, cal.get(Calendar.MONTH));
    assertEquals(31, cal.get(Calendar.DAY_OF_MONTH));

    // GMT
    parsedDate = formatter.parse("2003-03-18Z");
    cal.setTime(parsedDate);
    cal.setTimeZone(TimeZone.getTimeZone("GMT"));
    assertEquals(2003, cal.get(Calendar.YEAR));
    assertEquals(Calendar.MARCH, cal.get(Calendar.MONTH));
    assertEquals(18, cal.get(Calendar.DAY_OF_MONTH));

    // no TZ
    parsedDate = formatter.parse("1999-07-28");
    cal.setTime(parsedDate);
    cal.setTimeZone(TimeZone.getDefault());
    assertEquals(1999, cal.get(Calendar.YEAR));
    assertEquals(Calendar.JULY, cal.get(Calendar.MONTH));
    assertEquals(28, cal.get(Calendar.DAY_OF_MONTH));
View Full Code Here

Examples of com.skaringa.util.ISO8601DateFormat

  /**
   * Test reporting of parsing error.
   */
  public void testParseException() {
    String wrong = "1999-mar-01";
    ISO8601DateFormat formatter = new ISO8601DateFormat();

    ParsePosition pos = new ParsePosition(0);
    Date res = formatter.parse(wrong, pos);

    assertNull("A null value should have been returned.", res);

    assertEquals(
      "The wrong parse position is reported in case of error.",
View Full Code Here

Examples of org.apache.log4j.helpers.ISO8601DateFormat

        // Doing that efficiently probably means cutting out all the
        // excess buffer copies here, and appending into an OutputBuffer.
        byte[] data;
        if (FAKE_LOG4J_HEADER) {
          StringBuilder result = new StringBuilder();
          ISO8601DateFormat dateFormat = new org.apache.log4j.helpers.ISO8601DateFormat();
          result.append(dateFormat.format(new java.util.Date()));
          result.append(" INFO org.apache.hadoop.chukwa.");
          result.append(type);
          result.append("= ");
          result.append(o.get("exitValue"));
          result.append(": ");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.