<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    Hi,<br>
    <br>
    Java.time has a clear definition of negative years.<br>
    It would need a closer look as to j.u.Formatter's interpretation of
    negative years, though it should be consistent for j.t.LocalDate.<br>
    <br>
    Created:<br>
    <a class="issue-link" data-issue-key="JDK-8317742" href="https://bugs.openjdk.org/browse/JDK-8317742" id="key-val" rel="5111985">8317742</a> ISO Starndard Date Format implementation
    consistency on DateTimeFormatter and String.format<br>
    <br>
    Regards, Roger<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 10/4/23 10:22 AM, 温绍锦(高铁) wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:875b3104-40f7-48b9-b003-b19ac5e2ce09.shaojin.wensj@alibaba-inc.com">
      
      <div class="__aliyun_email_body_block">
        <div style="line-height:1.7;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#0070c0;">
          <div style="clear:both;">j.t.DateTimeFormatter defines
            ISO_LOCAL_DATE, j.u.Formatter.DateTime also defines
            ISO_STANDARD_DATE ("%tF"), and now their behavior is
            different outside the range of [0,9999], We run the
            following code and we can see their different behaviors:<br>
          </div>
          <div style="clear:both;"><span><span><br>
              </span></span></div>
          <div style="clear:both;"><span>```java</span></div>
          <div style="clear:both;"><span>DateTimeFormatter formatter =
              DateTimeFormatter.ISO_LOCAL_DATE;</span>
            <div style="clear:both;">int[] years = {-99999, -9999, -999,
              -99, -9, 0, 9, 99, 999, 1999, 2999, 9999, 99999};</div>
            <div style="clear:both;">for (int year : years) {</div>
            <div style="clear:both;">    LocalDate localDate =
              LocalDate.of(year, 1, 1);</div>
            <div style="clear:both;">   
              System.out.println(formatter.format(localDate) +
              "\t\t->\t\t" + "%tF".formatted(localDate));</div>
            <div><span>}</span></div>
          </div>
          <div style="clear:both;"><span>```</span></div>
          <div style="clear:both;"><span><br>
            </span></div>
          <div style="clear:both;"><span>* output</span></div>
          <div style="clear:both;"><span>```</span></div>
          <div style="clear:both;"><span>-99999-01-01  -> 
              100000-01-01</span>
            <div style="clear:both;">-9999-01-01  ->  10000-01-01</div>
            <div style="clear:both;">-0999-01-01  ->  1000-01-01</div>
            <div style="clear:both;">-0099-01-01  ->  0100-01-01</div>
            <div style="clear:both;">-0009-01-01  ->  0010-01-01</div>
            <div style="clear:both;">0000-01-01  ->  0001-01-01</div>
            <div style="clear:both;">0009-01-01  ->  0009-01-01</div>
            <div style="clear:both;">0099-01-01  ->  0099-01-01</div>
            <div style="clear:both;">0999-01-01  ->  0999-01-01</div>
            <div style="clear:both;">1999-01-01  ->  1999-01-01</div>
            <div style="clear:both;">2999-01-01  ->  2999-01-01</div>
            <div style="clear:both;">9999-01-01  ->  9999-01-01</div>
            <div><span>+99999-01-01  ->  99999-01-01</span></div>
          </div>
          <div style="clear:both;"><span>```</span></div>
          <div style="clear:both;"><span><br>
            </span></div>
          <div style="clear:both;"><span><span style="color:#0070c0;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;word-spacing:.0px;white-space:normal;background-color:#ffffff;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;">Should
                we keep it consistent?</span></span></div>
          <div style="clear:both;"><span><span style="color:#0070c0;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;word-spacing:.0px;white-space:normal;background-color:#ffffff;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;"><br>
              </span></span></div>
          <div style="clear:both;"><span><span style="color:#0070c0;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;word-spacing:.0px;white-space:normal;background-color:#ffffff;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;">-
                wenshao</span></span></div>
          <div style="clear:both;"><span><br>
            </span></div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>