Add Joda library support

This commit is contained in:
anujgaud 2023-11-18 00:58:52 +05:30 committed by GitHub
parent eaf6ce5fbe
commit 293322e3a3
1 changed files with 11 additions and 0 deletions

View File

@ -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;
}
}