How to query LocalDateTime with LocalDate?

后端 未结 5 1187
一向
一向 2021-01-22 02:49

I\'ve got a class which contains an atttribute of java.time.LocalDateTime type.

public class MyClass{
    // ...
    private LocalDateTime fecha;
    // ...
}
         


        
5条回答
  •  遥遥无期
    2021-01-22 03:07

    Try this (not tested):

    public interface IRepository extends CrudRepository {
        // ...
        default void delByFecha(LocalDate fecha) {
    
            deleteByFechaBetween(fecha.atStartOfDay(), fecha.plusDays(1).atStartOfDay());
    
        }
    
        void deleteByFechaBetween(LocalDateTime from, LocalDateTime to);
        // ...
    }
    

提交回复
热议问题