
com.bluecatcode.time.ISO8601 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of joda-time-2.9.1-extended Show documentation
Show all versions of joda-time-2.9.1-extended Show documentation
Joda Time library extensions.
package com.bluecatcode.time;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
import java.util.Date;
/**
* Ensures ISO 8601 date time format with UTC timezone
*/
public class ISO8601 {
public static Date isoToDate(String date) {
return isoToDateTime(date).toDate();
}
public static String dateToIso(Date date) {
DateTime dateTime = new DateTime(date);
return dateTimeToIso(dateTime);
}
public static DateTime isoToDateTime(String dateTime) {
DateTimeFormatter parser = ISODateTimeFormat.dateTimeParser().withZoneUTC();
return parser.parseDateTime(dateTime);
}
public static String dateTimeToIso(DateTime dateTime) {
DateTimeFormatter formatter = ISODateTimeFormat.dateTimeNoMillis().withZoneUTC();
return formatter.print(dateTime);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy