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

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


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


    }

    public void testFormatDate() {
        Calendar cal = getCalendar(TimeZone.getTimeZone("GMT"));
        assertEquals(0, cal.get(Calendar.MILLISECOND));
        XsDateFormat format = new XsDateFormat();
        String got = format.format(cal);
        String expect = "2004-01-14Z";
        assertEquals(expect, got);

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

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

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

   *   instance of {@link org.apache.ws.jaxme.xs.util.XsDateFormat}
   *   (default).
   */
  public Format getDateFormat() {
    if (dateFormat == null) {
      dateFormat = new XsDateFormat();
    }
    return dateFormat;
  }
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(){
    private static final long serialVersionUID = -6173879133371739286L;
View Full Code Here

        }
        return cal;
    }

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

    public String printTime(Calendar arg0) {
        return new XsTimeFormat().format(arg0);
    }

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

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

     * {@link org.apache.ws.jaxme.xs.util.XsDateFormat#format(Object, StringBuffer, java.text.FieldPosition)}.
     */
    public void testFormatDate() {
        Calendar cal = getCalendar(TimeZone.getTimeZone("GMT"));
        assertEquals(0, cal.get(Calendar.MILLISECOND));
        XsDateFormat format = new XsDateFormat();
        String got = format.format(cal);
        String expect = "2004-01-14Z";
        assertEquals(expect, got);

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

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

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

TOP

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

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.