How do I compare two dates created as jodatime localdate and localdatetime?

LocalDate startDate = new LocalDate(2014,1,2);
LocalDate startDate = new LocalDate(2014,1,2);

LocalDateTime startDateTime = new LocalDateTime(2014,2,14,0);

I need to compare the dates related to StartDate and startdatetime, as shown below:

// boolean equalDates = startDate.isequal(startDateTime.getDate());

Is it possible to do this?

Solution

If you only want to compare the date part, you can do this:

LocalDate startDate = new LocalDate(2014,2);
LocalDateTime startDateTime = new LocalDateTime(2014,0);
LocalDate forCompare = startDateTime.toLocalDate();
System.out.println("equal dates: " + forCompare.equals(startDate));
// equal dates: true

docs

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>