import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.DateTimeFormat; public class DateCalcExample { public static void main(String[] args) { DateTime dateTime = new DateTime(2022, 1, 1, 0, 0, 0); DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); String formattedDate = dateTime.toString(formatter); System.out.println("Formatted date: " + formattedDate); DateTime anotherDateTime = new DateTime(2023, 1, 1, 0, 0, 0); boolean isAfter = dateTime.isAfter(anotherDateTime); System.out.println("Is the first date after the second date? " + isAfter); DateTime modifiedDateTime = dateTime.plusDays(7); System.out.println("Modified date: " + modifiedDateTime.toString(formatter)); } }


上一篇:
下一篇:
切换中文