Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support alternate date formats in StateMachine.fromJson(). #3095

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package com.amazonaws.services.stepfunctions.builder.internal;

import com.amazonaws.util.DateUtils;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
Expand Down Expand Up @@ -59,7 +60,7 @@ public Date deserialize(JsonParser jsonParser,
}

public static Date fromJson(String jsonText) {
return FORMATTER.parseDateTime(jsonText).toDate();
return DateUtils.parseISO8601Date(jsonText);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -667,4 +667,18 @@ public void stateMachineFromJson_MalformedJson_ThrowsException() {
StateMachine.fromJson("{");
}

@Test
public void stateMachineFromJson_JsonWithTimestampWithFractionalSeconds_DoesNotThrowException() {
StateMachine.fromJson(
"{\"StartAt\":\"TestTime\",\"States\":{\"TestTime\":{\"Type\":\"Wait\",\"Timestamp\":\"2016-03-14T01:59:00.000Z\",\"End\":true}}}"
);
}

@Test
public void stateMachineFromJson_JsonWithTimestampWithoutFractionalSeconds_DoesNotThrowException() {
StateMachine.fromJson(
"{\"StartAt\":\"TestTime\",\"States\":{\"TestTime\":{\"Type\":\"Wait\",\"Timestamp\":\"2016-03-14T01:59:00Z\",\"End\":true}}}"
);
}

}