Code: Select all
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import java.util.Date;
DateTimeFormatter DATE_TIME_FORMATTER
= DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'");
String transactionTime = "2019-02-26T13:43:12Z";
Date txnTime = DATE_TIME_FORMATTER.parseDateTime(transactionTime).toDate();
Code: Select all
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
DateTimeFormatter DATE_TIME_FORMATTER
= DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'");
String transactionTime = "2019-02-26T13:43:12Z";
OffsetDateTime txnTime = OffsetDateTime.from(
OffsetDateTime.parse(transactionTime, DATE_TIME_FORMATTER)
.toInstant());
Code: Select all
Text '2019-02-26T13:43:12Z' could not be parsed: Unable to obtain OffsetDateTime from TemporalAccessor: {},ISO resolved to 2019-02-26T13:43:12 of type java.time.format.Parsed
Code: Select all
OffsetDateTime txnTime = OffsetDateTime.from(
OffsetDateTime.parse(transactionTime).toInstant()