jaxp
  1. jaxp
  2. JAXP-57

XMLGregorianCalendar's method "toString()" sometimes brakes ISO date format in fractional seconds

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: www
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      57

      Description

      XMLGregorianCalendar is used by JAX-WS to generate values for xs:dateTime in XML
      documents. Sometimes, the output is broken and contains illegal characters; here
      "E-9" instead of fractional seconds.

      The code of my converter routine is:
      public static final XMLGregorianCalendar xmlValueOf(
      java.sql.Timestamp sqlValue )
      {
      logger.log(
      Level.FINE, "java.sql.Timestamp sqlValue=

      {0}", sqlValue.toString() );
      if (sqlValue == null) { return null; }
      GregorianCalendar calendar = new GregorianCalendar(UTC_TZ, Locale.ROOT);
      logger.log(Level.FINER, "GregorianCalendar calendar={0}

      ", calendar);
      calendar.setTime(new Date(sqlValue.getTime()));
      logger.log(Level.FINER, "GregorianCalendar calendar=

      {0}", calendar);
      XMLGregorianCalendar result
      = datatypeFactory.newXMLGregorianCalendar(calendar);
      logger.log(Level.FINER, "XMLGregorianCalendar result={0}

      ", result);
      int sqlNanoseconds = sqlValue.getNanos();
      logger.log(
      Level.FINER, "java.sql.Timestamp int nanoseconds=

      {0}", sqlNanoseconds );
      BigDecimal nanoseconds = new BigDecimal(sqlNanoseconds);
      logger.log(Level.FINER, "BigDecimal nanoseconds={0}

      ", nanoseconds);
      BigDecimal nanosecondsFractional
      = nanoseconds.divide(BILLION, 9, RoundingMode.HALF_UP);
      logger.log(
      Level.FINER,
      "BigDecimal nanosecondsFractional=

      {0}", nanosecondsFractional );
      result.setFractionalSecond(nanosecondsFractional);
      logger.log(Level.FINE, "XMLGregorianCalendar result={0}

      ", result);
      return result;
      }

      And here is an example for broken output:

      FEIN: java.sql.Timestamp sqlValue=2009-02-01 00:00:00.0
      FEINER: GregorianCalendar
      calendar=java.util.GregorianCalendar[time=1235046117468,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2009,MONTH=1,WEEK_OF_YEAR=8,WEEK_OF_MONTH=3,DAY_OF_MONTH=19,DAY_OF_YEAR=50,DAY_OF_WEEK=5,DAY_OF_WEEK_IN_MONTH=3,AM_PM=1,HOUR=0,HOUR_OF_DAY=12,MINUTE=21,SECOND=57,MILLISECOND=468,ZONE_OFFSET=0,DST_OFFSET=0]
      FEINER: GregorianCalendar
      calendar=java.util.GregorianCalendar[time=1233446400000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2009,MONTH=1,WEEK_OF_YEAR=6,WEEK_OF_MONTH=1,DAY_OF_MONTH=1,DAY_OF_YEAR=32,DAY_OF_WEEK=1,DAY_OF_WEEK_IN_MONTH=1,AM_PM=0,HOUR=0,HOUR_OF_DAY=0,MINUTE=0,SECOND=0,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0]
      FEINER: XMLGregorianCalendar result=2009-02-01T00:00:00.000Z
      FEINER: java.sql.Timestamp int nanoseconds=0
      FEINER: BigDecimal nanoseconds=0
      FEINER: BigDecimal nanosecondsFractional=0
      FEIN: XMLGregorianCalendar result=2009-02-01T00:00:00E-9Z

      The XML SOAP request sent included the following broken xs:dateTime value:

      <startUTC>2009-02-01T00:00:00E-9Z</startUTC>

      It seems that "setFractionalSecond()" triggers the error here.

      We need microseconds in our application, therefore "java.util.Date" or
      "java.util.GregorianCalendar" is not useable.

        Activity

        genoko created issue -
        kenaiadmin made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 57 46741

          People

          • Assignee:
            jaxp-issues
            Reporter:
            genoko
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: