Skip to content

How to use AWSDateTime in Java

Trying to figure out how to input a AWSDateTime. I don’t want to use Java 8.

createDate requires Temporal.DateTime

public static final class Temporal.DateTime

private final @ModelField(targetType="AWSDateTime", isRequired = true) Temporal.DateTime createDate;

Is there any other way I can accomplish this?

Date input = new Date();
LocalDate date = input.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); --> this requires Java 8

Todo todo = Todo .builder()
        result -> Log.i("MyAmplifyApp", "Created successfully"),
        error -> Log.e("MyAmplifyApp",  "Error creating", error)


I ended up using the function in DateUtils.


An extended ISO 8601 date and time string in the format YYYY-MM-DDThh:mm:ss.sssZ.

String date1 = com.amazonaws.util.DateUtils.formatISO8601Date(new Date());

Todo todo = Todo .builder()
        .createDate(new Temporal.DateTime(date1))

Note: This will store the date in GMT time.