2
votes

DynamoDB API documentation tells that a supported date should be a String like:

Date (as ISO8601 millisecond-precision string, shifted to UTC)

How do I get this current Date format in Java?

I saw similar things, but they are not quite exactly:

DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmZ");

Is millisecond precision really necessary?

Hopefully I won't need to add Joda for this.

Need a time stamp, to add it to my Range Primary Key.

Need this to put/insert into the Db.

1

1 Answers

2
votes

Using Joda,(planned to avoid it) this code seems to do the trick:

    DateTime dt = new DateTime(DateTimeZone.UTC);
    DateTimeFormatter fmt = ISODateTimeFormat.basicDateTime();
    String str = fmt.print(dt); 
    //20140710T160939.473Z