com.litongjava.tio.utils.date.DateParseUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tio-utils Show documentation
Show all versions of tio-utils Show documentation
t-io is a aio framework for java
package com.litongjava.tio.utils.date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
public class DateParseUtils {
/**
* Parses an ISO 8601 date string to a java.util.Date object.
*
* @param dateString The ISO 8601 date string.
* @return The parsed Date object.
*/
public static Date parseIso8601Date(String dateString) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
formatter.setTimeZone(TimeZone.getTimeZone("UTC")); // Set the formatter to UTC
try {
return formatter.parse(dateString);
} catch (ParseException e) {
e.printStackTrace();
return null;
}
}
public static List convertToIso8601Date(List