@@ -388,6 +388,8 @@ private StringBuilder append(StringBuilder sb, int w, int d) {
388388 * href="http://www.w3.org/TR/NOTE-datetime">ISO 8601</a> format:
389389 * <pre>
390390 * YYYY-MM-DDThh:mm:ss[.s+]Z
391+ *
392+ *
391393 * </pre>
392394 * where "{@code [.s+]}" represents a dot followed by one of more digits
393395 * for the decimal fraction of a second. It is only present when the decimal
@@ -418,57 +420,61 @@ public String toString() {
418420 secs = toInstant ().getEpochSecond ();
419421 nanos = toInstant ().getNano ();
420422 }
421- LocalDateTime ldt ;
422- int year = 0 ;
423- if (secs >= -SECONDS_0000_TO_1970 ) {
424- // current era
425- long zeroSecs = secs - SECONDS_PER_10000_YEARS + SECONDS_0000_TO_1970 ;
426- long hi = Math .floorDiv (zeroSecs , SECONDS_PER_10000_YEARS ) + 1 ;
427- long lo = Math .floorMod (zeroSecs , SECONDS_PER_10000_YEARS );
428- ldt = LocalDateTime .ofEpochSecond (lo - SECONDS_0000_TO_1970 , nanos , ZoneOffset .UTC );
429- year = ldt .getYear () + (int )hi * 10000 ;
430- } else {
431- // before current era
432- long zeroSecs = secs + SECONDS_0000_TO_1970 ;
433- long hi = zeroSecs / SECONDS_PER_10000_YEARS ;
434- long lo = zeroSecs % SECONDS_PER_10000_YEARS ;
435- ldt = LocalDateTime .ofEpochSecond (lo - SECONDS_0000_TO_1970 , nanos , ZoneOffset .UTC );
436- year = ldt .getYear () + (int )hi * 10000 ;
437- }
438- if (year <= 0 ) {
439- year = year - 1 ;
440- }
441- int fraction = ldt .getNano ();
442- StringBuilder sb = new StringBuilder (64 );
443- sb .append (year < 0 ? "-" : "" );
444- year = Math .abs (year );
445- if (year < 10000 ) {
446- append (sb , 1000 , Math .abs (year ));
447- } else {
448- sb .append (String .valueOf (year ));
449- }
450- sb .append ('-' );
451- append (sb , 10 , ldt .getMonthValue ());
452- sb .append ('-' );
453- append (sb , 10 , ldt .getDayOfMonth ());
454- sb .append ('T' );
455- append (sb , 10 , ldt .getHour ());
456- sb .append (':' );
457- append (sb , 10 , ldt .getMinute ());
458- sb .append (':' );
459- append (sb , 10 , ldt .getSecond ());
460- if (fraction != 0 ) {
461- sb .append ('.' );
462- // adding leading zeros and stripping any trailing zeros
463- int w = 100_000_000 ;
464- while (fraction % 10 == 0 ) {
465- fraction /= 10 ;
466- w /= 10 ;
467- }
468- append (sb , w , fraction );
469- }
470- sb .append ('Z' );
471- valueAsString = sb .toString ();
423+ valueAsString = /** @j2sNative ? new Date(secs * 1000).toISOString() || */ "" ;
424+ //
425+ //
426+ //
427+ // LocalDateTime ldt;
428+ // int year = 0;
429+ // if (secs >= -SECONDS_0000_TO_1970) {
430+ // // current era
431+ // long zeroSecs = secs - SECONDS_PER_10000_YEARS + SECONDS_0000_TO_1970;
432+ // long hi = Math.floorDiv(zeroSecs, SECONDS_PER_10000_YEARS) + 1;
433+ // long lo = Math.floorMod(zeroSecs, SECONDS_PER_10000_YEARS);
434+ // ldt = LocalDateTime.ofEpochSecond(lo - SECONDS_0000_TO_1970, nanos, ZoneOffset.UTC);
435+ // year = ldt.getYear() + (int)hi * 10000;
436+ // } else {
437+ // // before current era
438+ // long zeroSecs = secs + SECONDS_0000_TO_1970;
439+ // long hi = zeroSecs / SECONDS_PER_10000_YEARS;
440+ // long lo = zeroSecs % SECONDS_PER_10000_YEARS;
441+ // ldt = LocalDateTime.ofEpochSecond(lo - SECONDS_0000_TO_1970, nanos, ZoneOffset.UTC);
442+ // year = ldt.getYear() + (int)hi * 10000;
443+ // }
444+ // if (year <= 0) {
445+ // year = year - 1;
446+ // }
447+ // int fraction = ldt.getNano();
448+ // StringBuilder sb = new StringBuilder(64);
449+ // sb.append(year < 0 ? "-" : "");
450+ // year = Math.abs(year);
451+ // if (year < 10000) {
452+ // append(sb, 1000, Math.abs(year));
453+ // } else {
454+ // sb.append(String.valueOf(year));
455+ // }
456+ // sb.append('-');
457+ // append(sb, 10, ldt.getMonthValue());
458+ // sb.append('-');
459+ // append(sb, 10, ldt.getDayOfMonth());
460+ // sb.append('T');
461+ // append(sb, 10, ldt.getHour());
462+ // sb.append(':');
463+ // append(sb, 10, ldt.getMinute());
464+ // sb.append(':');
465+ // append(sb, 10, ldt.getSecond());
466+ // if (fraction != 0) {
467+ // sb.append('.');
468+ // // adding leading zeros and stripping any trailing zeros
469+ // int w = 100_000_000;
470+ // while (fraction % 10 == 0) {
471+ // fraction /= 10;
472+ // w /= 10;
473+ // }
474+ // append(sb, w, fraction);
475+ // }
476+ // sb.append('Z');
477+ // valueAsString = sb.toString();
472478 }
473479 return valueAsString ;
474480 }
0 commit comments