Partial desugaring for LocalDate

Change-Id: I99259392e7f369c82a4b2c2cace7a37fe9d6bcab
diff --git a/src/library_desugar/jdk11/desugar_jdk_libs.json b/src/library_desugar/jdk11/desugar_jdk_libs.json
index d6649f7..1132b9a 100644
--- a/src/library_desugar/jdk11/desugar_jdk_libs.json
+++ b/src/library_desugar/jdk11/desugar_jdk_libs.json
@@ -7,6 +7,31 @@
   "common_flags": [
     {
       "api_level_below_or_equal": 10000,
+      "api_level_greater_or_equal": 26,
+      "rewrite_prefix": {
+        "java.time.DesugarLocalDate": "j$.time.DesugarLocalDate"
+      },
+      "retarget_static_field": {
+        "java.time.LocalDate java.time.LocalDate#EPOCH": "java.time.LocalDate java.time.DesugarLocalDate#EPOCH"
+      },
+      "retarget_method": {
+        "java.util.stream.Stream java.time.LocalDate#datesUntil(java.time.LocalDate)": "java.time.DesugarLocalDate",
+        "java.util.stream.Stream java.time.LocalDate#datesUntil(java.time.LocalDate, java.time.Period)": "java.time.DesugarLocalDate",
+        "java.time.LocalDate java.time.LocalDate#ofInstant(java.time.Instant, java.time.ZoneId)": "java.time.DesugarLocalDate",
+        "long java.time.LocalDate#toEpochSecond(java.time.LocalTime, java.time.ZoneOffset)": "java.time.DesugarLocalDate"
+      },
+      "amend_library_field": [
+        "public static java.time.LocalDate java.time.LocalDate#EPOCH"
+      ],
+      "amend_library_method": [
+        "public java.util.stream.Stream java.time.LocalDate#datesUntil(java.time.LocalDate)",
+        "public java.util.stream.Stream java.time.LocalDate#datesUntil(java.time.LocalDate, java.time.Period)",
+        "public static java.time.LocalDate java.time.LocalDate#ofInstant(java.time.Instant, java.time.ZoneId)",
+        "public long java.time.LocalDate#toEpochSecond(java.time.LocalTime, java.time.ZoneOffset)"
+      ]
+    },
+    {
+      "api_level_below_or_equal": 10000,
       "api_level_greater_or_equal": 24,
       "rewrite_prefix": {
         "java.util.stream.DesugarDoubleStream": "j$.util.stream.DesugarDoubleStream",
diff --git a/src/library_desugar/jdk11/desugar_jdk_libs_nio.json b/src/library_desugar/jdk11/desugar_jdk_libs_nio.json
index 98054a7..cd20a37 100644
--- a/src/library_desugar/jdk11/desugar_jdk_libs_nio.json
+++ b/src/library_desugar/jdk11/desugar_jdk_libs_nio.json
@@ -14,6 +14,31 @@
     },
     {
       "api_level_below_or_equal": 10000,
+      "api_level_greater_or_equal": 26,
+      "rewrite_prefix": {
+        "java.time.DesugarLocalDate": "j$.time.DesugarLocalDate"
+      },
+      "retarget_static_field": {
+        "java.time.LocalDate java.time.LocalDate#EPOCH": "java.time.LocalDate java.time.DesugarLocalDate#EPOCH"
+      },
+      "retarget_method": {
+        "java.util.stream.Stream java.time.LocalDate#datesUntil(java.time.LocalDate)": "java.time.DesugarLocalDate",
+        "java.util.stream.Stream java.time.LocalDate#datesUntil(java.time.LocalDate, java.time.Period)": "java.time.DesugarLocalDate",
+        "java.time.LocalDate java.time.LocalDate#ofInstant(java.time.Instant, java.time.ZoneId)": "java.time.DesugarLocalDate",
+        "long java.time.LocalDate#toEpochSecond(java.time.LocalTime, java.time.ZoneOffset)": "java.time.DesugarLocalDate"
+      },
+      "amend_library_field": [
+        "public static java.time.LocalDate java.time.LocalDate#EPOCH"
+      ],
+      "amend_library_method": [
+        "public java.util.stream.Stream java.time.LocalDate#datesUntil(java.time.LocalDate)",
+        "public java.util.stream.Stream java.time.LocalDate#datesUntil(java.time.LocalDate, java.time.Period)",
+        "public static java.time.LocalDate java.time.LocalDate#ofInstant(java.time.Instant, java.time.ZoneId)",
+        "public long java.time.LocalDate#toEpochSecond(java.time.LocalTime, java.time.ZoneOffset)"
+      ]
+    },
+    {
+      "api_level_below_or_equal": 10000,
       "api_level_greater_or_equal": 24,
       "rewrite_prefix": {
         "java.util.stream.DesugarDoubleStream": "j$.util.stream.DesugarDoubleStream",
diff --git a/src/test/examplesJava9/time/LocalDateMain.java b/src/test/examplesJava9/time/LocalDateMain.java
new file mode 100644
index 0000000..79077bb
--- /dev/null
+++ b/src/test/examplesJava9/time/LocalDateMain.java
@@ -0,0 +1,25 @@
+// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+package time;
+
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalTime;
+import java.time.Period;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
+
+public class LocalDateMain {
+
+  public static void main(String[] args) {
+    System.out.println(LocalDate.EPOCH);
+    System.out.println(LocalDate.ofInstant(Instant.EPOCH, ZoneId.ofOffset("UTC", ZoneOffset.UTC)));
+    System.out.println(LocalDate.EPOCH.toEpochSecond(LocalTime.NOON, ZoneOffset.UTC));
+    System.out.println(LocalDate.EPOCH.datesUntil(LocalDate.EPOCH).count());
+    System.out.println(LocalDate.EPOCH.datesUntil(LocalDate.EPOCH, Period.of(1, 1, 1)).count());
+    System.out.println(
+        LocalDate.EPOCH.datesUntil(LocalDate.ofEpochDay(7), Period.of(0, 0, 1)).count());
+  }
+}
diff --git a/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/jdk11/NewLocalDateTest.java b/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/jdk11/NewLocalDateTest.java
new file mode 100644
index 0000000..d942e79
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/jdk11/NewLocalDateTest.java
@@ -0,0 +1,63 @@
+// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+package com.android.tools.r8.desugar.desugaredlibrary.jdk11;
+
+import static com.android.tools.r8.desugar.desugaredlibrary.test.CompilationSpecification.DEFAULT_SPECIFICATIONS;
+import static com.android.tools.r8.desugar.desugaredlibrary.test.LibraryDesugaringSpecification.JDK11;
+import static com.android.tools.r8.desugar.desugaredlibrary.test.LibraryDesugaringSpecification.JDK11_PATH;
+
+import com.android.tools.r8.TestParameters;
+import com.android.tools.r8.ToolHelper;
+import com.android.tools.r8.desugar.desugaredlibrary.DesugaredLibraryTestBase;
+import com.android.tools.r8.desugar.desugaredlibrary.test.CompilationSpecification;
+import com.android.tools.r8.desugar.desugaredlibrary.test.LibraryDesugaringSpecification;
+import com.android.tools.r8.utils.StringUtils;
+import com.google.common.collect.ImmutableList;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class NewLocalDateTest extends DesugaredLibraryTestBase {
+
+  private final TestParameters parameters;
+  private final LibraryDesugaringSpecification libraryDesugaringSpecification;
+  private final CompilationSpecification compilationSpecification;
+
+  private static final Path INPUT_JAR = Paths.get(ToolHelper.EXAMPLES_JAVA9_BUILD_DIR + "time.jar");
+  private static final String EXPECTED_OUTPUT =
+      StringUtils.lines("1970-01-01", "1970-01-01", "43200", "0", "0", "7");
+  private static final String MAIN_CLASS = "time.LocalDateMain";
+
+  @Parameters(name = "{0}, spec: {1}, {2}")
+  public static List<Object[]> data() {
+    return buildParameters(
+        getTestParameters().withDexRuntimes().withAllApiLevels().build(),
+        ImmutableList.of(JDK11, JDK11_PATH),
+        DEFAULT_SPECIFICATIONS);
+  }
+
+  public NewLocalDateTest(
+      TestParameters parameters,
+      LibraryDesugaringSpecification libraryDesugaringSpecification,
+      CompilationSpecification compilationSpecification) {
+    this.parameters = parameters;
+    this.libraryDesugaringSpecification = libraryDesugaringSpecification;
+    this.compilationSpecification = compilationSpecification;
+  }
+
+  @Test
+  public void test() throws Throwable {
+    testForDesugaredLibrary(parameters, libraryDesugaringSpecification, compilationSpecification)
+        .addProgramFiles(INPUT_JAR)
+        .addKeepMainRule(MAIN_CLASS)
+        .run(parameters.getRuntime(), MAIN_CLASS)
+        .assertSuccessWithOutput(EXPECTED_OUTPUT);
+  }
+}