如何比较创建为JodaTime LocalDate和LocalDateTime的两个日期?

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

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

我需要比较startDate和startDateTime相关的日期,如下所示:

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

是否有可能做到这一点?

解决方法

如果您只想比较日期部分,可以这样做:
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

相关文章

应用场景 C端用户提交工单、工单创建完成之后、会发布一条工...
线程类,设置有一个公共资源 package cn.org.chris.concurre...
Java中的数字(带有0前缀和字符串)
在Java 9中使用JLink的目的是什么?
Java Stream API Filter(过滤器)
在Java中找到正数和负数数组元素的数量