Skip to content

Commit 32ddf0d

Browse files
committed
Rewrite timestamp formatting using Java 8 Instant
1 parent 9e0a13c commit 32ddf0d

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ mavenPublishing {
264264
dependencies {
265265
annotationProcessor(libs.nullaway)
266266
api(libs.protobuf.java)
267-
implementation(libs.protobuf.java.util)
268267
implementation(enforcedPlatform(libs.cel))
269268
implementation(libs.cel.core)
270269
implementation(libs.guava)

gradle/libs.versions.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" }
2525
maven-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "maven-publish" }
2626
nullaway = { module = "com.uber.nullaway:nullaway", version = "0.12.1" }
2727
protobuf-java = { module = "com.google.protobuf:protobuf-java", version.ref = "protobuf" }
28-
protobuf-java-util = { module = "com.google.protobuf:protobuf-java-util", version.ref = "protobuf" }
2928
spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version = "6.25.0" }
3029

3130
[plugins]

src/main/java/build/buf/protovalidate/internal/celext/Format.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414

1515
package build.buf.protovalidate.internal.celext;
1616

17+
import static java.time.format.DateTimeFormatter.ISO_INSTANT;
18+
1719
import com.google.protobuf.Duration;
1820
import com.google.protobuf.Timestamp;
19-
import com.google.protobuf.util.Timestamps;
2021
import java.nio.charset.StandardCharsets;
2122
import java.text.DecimalFormat;
23+
import java.time.Instant;
2224
import java.util.List;
2325
import org.projectnessie.cel.common.types.Err.ErrException;
2426
import org.projectnessie.cel.common.types.IntT;
@@ -214,7 +216,8 @@ private static void formatList(StringBuilder builder, Val val) {
214216
*/
215217
private static void formatTimestamp(StringBuilder builder, Val val) {
216218
Timestamp timestamp = val.convertToNative(Timestamp.class);
217-
builder.append(Timestamps.toString(timestamp));
219+
Instant instant = Instant.ofEpochSecond(timestamp.getSeconds(), timestamp.getNanos());
220+
builder.append(ISO_INSTANT.format(instant));
218221
}
219222

220223
/**

0 commit comments

Comments
 (0)