Add Joda library support
This commit is contained in:
parent
eaf6ce5fbe
commit
293322e3a3
|
@ -9,6 +9,10 @@ import java.util.Date;
|
|||
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
|
||||
public class LocalDateToISO {
|
||||
public String formatUsingDateTimeFormatter(LocalDate localDate) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssX");
|
||||
|
@ -22,4 +26,11 @@ public class LocalDateToISO {
|
|||
String formattedDate = dateFormat.format(utilDate);
|
||||
return formattedDate;
|
||||
}
|
||||
|
||||
public String formatUsingJodaTime(org.joda.time.LocalDate localDate) {
|
||||
DateTime dateTime = localDate.toDateTimeAtStartOfDay(DateTimeZone.UTC);
|
||||
org.joda.time.format.DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||
String formattedDate = formatter.print(localDate);
|
||||
return formattedDate;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue