diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/ProjectInfo.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/ProjectInfo.java index 75e2021b6194..d20c3ccd86e3 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/ProjectInfo.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/ProjectInfo.java @@ -29,8 +29,9 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; -import org.joda.time.DateTime; -import org.joda.time.format.ISODateTimeFormat; +import org.threeten.bp.Instant; +import org.threeten.bp.ZoneOffset; +import org.threeten.bp.format.DateTimeFormatter; /** * A Google Cloud Resource Manager project metadata object. A Project is a high-level Google Cloud @@ -39,6 +40,8 @@ */ public class ProjectInfo implements Serializable { + public static final DateTimeFormatter DATE_TIME_FORMATTER = + DateTimeFormatter.ISO_DATE_TIME.withZone(ZoneOffset.UTC); private static final long serialVersionUID = 9148970963697734236L; private final String name; private final String projectId; @@ -390,7 +393,10 @@ com.google.api.services.cloudresourcemanager.model.Project toPb() { projectPb.setLifecycleState(state.toString()); } if (createTimeMillis != null) { - projectPb.setCreateTime(ISODateTimeFormat.dateTime().withZoneUTC().print(createTimeMillis)); + projectPb.setCreateTime( + DateTimeFormatter.ISO_DATE_TIME + .withZone(ZoneOffset.UTC) + .format(Instant.ofEpochMilli(createTimeMillis))); } if (parent != null) { projectPb.setParent(parent.toPb()); @@ -411,7 +417,8 @@ static ProjectInfo fromPb(com.google.api.services.cloudresourcemanager.model.Pro builder.setState(State.valueOf(projectPb.getLifecycleState())); } if (projectPb.getCreateTime() != null) { - builder.setCreateTimeMillis(DateTime.parse(projectPb.getCreateTime()).getMillis()); + builder.setCreateTimeMillis( + DATE_TIME_FORMATTER.parse(projectPb.getCreateTime(), Instant.FROM).toEpochMilli()); } if (projectPb.getParent() != null) { builder.setParent(ResourceId.fromPb(projectPb.getParent())); diff --git a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/testing/LocalResourceManagerHelper.java b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/testing/LocalResourceManagerHelper.java index 70163f00f6a3..bbaa25d72ae8 100644 --- a/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/testing/LocalResourceManagerHelper.java +++ b/java-resourcemanager/google-cloud-resourcemanager/src/main/java/com/google/cloud/resourcemanager/testing/LocalResourceManagerHelper.java @@ -61,7 +61,9 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; -import org.joda.time.format.ISODateTimeFormat; +import org.threeten.bp.Instant; +import org.threeten.bp.ZoneOffset; +import org.threeten.bp.format.DateTimeFormatter; /** * Utility to create a local Resource Manager mock for testing. @@ -443,7 +445,10 @@ synchronized Response create(Project project) { } else { project.setLifecycleState("ACTIVE"); project.setProjectNumber(Math.abs(PROJECT_NUMBER_GENERATOR.nextLong() % Long.MAX_VALUE)); - project.setCreateTime(ISODateTimeFormat.dateTime().print(System.currentTimeMillis())); + project.setCreateTime( + DateTimeFormatter.ISO_DATE_TIME + .withZone(ZoneOffset.UTC) + .format(Instant.ofEpochMilli(System.currentTimeMillis()))); if (projects.putIfAbsent(project.getProjectId(), project) != null) { return Error.ALREADY_EXISTS.response( "A project with the same project ID (" + project.getProjectId() + ") already exists.");