How to store java.sql.Date in cassandra date field using mapping manager?

前端 未结 2 1360
再見小時候
再見小時候 2021-01-07 11:32

Can someone help me to store the current system date in cassandra date column in format yyyy-mm-dd using Java? I get exception while saving the java.sql.D

2条回答
  •  时光说笑
    2021-01-07 12:25

    I had similar issues and As per Ashraful's answer, I have added below code in my model which resolved the issue.

    Meta Data Model:
    
    public class MetaData {
    private String receive_date;
    private String receive_hour;
    **private com.datastax.driver.core.LocalDate error_date;**
    }
    
    In my service class, added below code.
    final MetaData metaData = MetaData.builder()
                        .receive_date(row.getString("receive_date"))
                        .receive_hour(row.getString("receive_hour"))
                        .error_date(row.getDate("error_date"))
                        .build();
    

提交回复
热议问题