You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/12/07 01:20:33 UTC

[GitHub] [shardingsphere] chenjipdc commented on issue #8470: DateTimeParseException

chenjipdc commented on issue #8470:
URL: https://github.com/apache/shardingsphere/issues/8470#issuecomment-739609077


   In my project I use the following method to solve this problem.
   
   ```java
   private static final String FORMAT = "yyyy-MM-dd HH:mm:ss";
   private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat(FORMAT);
   
   private long parseDate(final Comparable<?> shardingValue) {
       String value;
       if (shardingValue instanceof Date){
           value = SIMPLE_DATE_FORMAT.format(shardingValue);
       }else {
           value = shardingValue.toString();
       }
       LocalDateTime dateValue = LocalDateTime.parse(value, DATE_TIME_FORMAT);
       return Duration.between(dateTimeLower, dateValue).toMillis() / 1000;
   }
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org