Package org.apache.ws.jaxme.xs.util

Examples of org.apache.ws.jaxme.xs.util.XsDateTimeFormat


   *   instance of {@link org.apache.ws.jaxme.xs.util.XsDateTimeFormat}
   *   (default).
   */
public Format getDateTimeFormat() {
      if (dateTimeFormat == null) {
          dateTimeFormat = new XsDateTimeFormat();
      }
      return dateTimeFormat;
  }
View Full Code Here


    }

    public void testFormatDateTime() {
        Calendar cal = getCalendar(TimeZone.getTimeZone("GMT"));
        assertEquals(0, cal.get(Calendar.MILLISECOND));
        XsDateTimeFormat format = new XsDateTimeFormat();
        String got = format.format(cal);
        String expect = "2004-01-14T03:12:07Z";
        assertEquals(expect, got);

        cal = getCalendar(TimeZone.getTimeZone("GMT-03:00"));
        assertEquals(0, cal.get(Calendar.MILLISECOND));
        got = format.format(cal);
        expect = "2004-01-14T03:12:07-03:00";
        assertEquals(expect, got);
    }
View Full Code Here

      "2004-01-14T03:12:07.000Z",
      "2004-01-14T03:12:07",
      "2004-01-14T03:12:07-00:00",
      "2004-01-14T03:12:07+00:00",
    };
        XsDateTimeFormat format = new XsDateTimeFormat();
        Calendar expect = getCalendar(TimeZone.getTimeZone("GMT"));
        for (int i = 0;  i < dateTimes.length;  i++) {
            Calendar got = (Calendar) format.parseObject(dateTimes[0]);
            assertEquals(expect.getTimeInMillis(), got.getTimeInMillis());
        }

        String dateTime = "2004-01-14T03:12:07.000-03:00";
        expect = getCalendar(TimeZone.getTimeZone("GMT-03:00"));
        Calendar got = (Calendar) format.parseObject(dateTime);
        assertEquals(expect.getTimeInMillis(), got.getTimeInMillis());
    }
View Full Code Here

   *   instance of {@link org.apache.ws.jaxme.xs.util.XsDateTimeFormat}
   *   (default).
   */
  public Format getDateTimeFormat() {
    if (dateTimeFormat == null) {
      dateTimeFormat = new XsDateTimeFormat();
    }
    return dateTimeFormat;
  }
View Full Code Here

  /** <p>Tests marshalling and unmarshalling of an element with "xs:all"
   * contents.</p>
   */
  public void testAllElement() throws Exception {
    final Format defaultDateTimeFormat = new XsDateTimeFormat();
    final Format defaultDateFormat = new XsDateFormat();
    final Format defaultTimeFormat = new XsTimeFormat();
    testAllElement(defaultDateTimeFormat, defaultDateFormat, defaultTimeFormat);

    final Format otherDateTimeFormat = new Format(){
View Full Code Here

    }

    /** Test for JAXME-42 in Jira.
     */
    public void testJira42() throws Exception {
      XsDateTimeFormat f = new XsDateTimeFormat();
        Calendar cal = (Calendar) f.parseObject("2004-10-15T13:00:00Z");
        assertEquals(2004, cal.get(Calendar.YEAR));
        assertEquals(9, cal.get(Calendar.MONTH));
        assertEquals(15, cal.get(Calendar.DAY_OF_MONTH));
        assertEquals(13, cal.get(Calendar.HOUR_OF_DAY));
        assertEquals(0, cal.get(Calendar.MINUTE));
        assertEquals(0, cal.get(Calendar.SECOND));
        assertEquals(0, cal.get(Calendar.MILLISECOND));
        assertEquals(TimeZone.getTimeZone("GMT"), cal.getTimeZone());

        String s = f.format(cal);
        assertEquals("2004-10-15T13:00:00Z", s);
    }
View Full Code Here

        }
        return new QName(uri, localName);
    }

    public Calendar parseDateTime(String arg0) {
        XsDateTimeFormat format = new XsDateTimeFormat();
        ParsePosition pos = new ParsePosition(0);
        Calendar cal = (Calendar) format.parseObject(arg0, pos);
        if (cal == null) {
            throw new IllegalArgumentException("Failed to parse dateTime " + arg0 +
                                   " at:" + arg0.substring(pos.getErrorIndex()));
        }
        return cal;
View Full Code Here

            return prefix + ":" + arg0.getLocalPart();
        }
    }

    public String printDateTime(Calendar arg0) {
        return new XsDateTimeFormat().format(arg0);
    }
View Full Code Here

   *   instance of {@link org.apache.ws.jaxme.xs.util.XsDateTimeFormat}
   *   (default).
   */
  public Format getDateTimeFormat() {
    if (dateTimeFormat == null) {
      dateTimeFormat = new XsDateTimeFormat();
    }
    return dateTimeFormat;
  }
View Full Code Here

    }

    /** Test for JAXME-42 in Jira.
     */
    public void testJira42() throws Exception {
      XsDateTimeFormat f = new XsDateTimeFormat();
        Calendar cal = (Calendar) f.parseObject("2004-10-15T13:00:00Z");
        assertEquals(2004, cal.get(Calendar.YEAR));
        assertEquals(9, cal.get(Calendar.MONTH));
        assertEquals(15, cal.get(Calendar.DAY_OF_MONTH));
        assertEquals(13, cal.get(Calendar.HOUR_OF_DAY));
        assertEquals(0, cal.get(Calendar.MINUTE));
        assertEquals(0, cal.get(Calendar.SECOND));
        assertEquals(0, cal.get(Calendar.MILLISECOND));
        assertEquals(TimeZone.getTimeZone("GMT"), cal.getTimeZone());

        String s = f.format(cal);
        assertEquals("2004-10-15T13:00:00Z", s);
    }
View Full Code Here

TOP

Related Classes of org.apache.ws.jaxme.xs.util.XsDateTimeFormat

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.