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/02 07:27:16 UTC

[GitHub] [shardingsphere] chenjipdc opened a new issue #8470: DateTimeParseException

chenjipdc opened a new issue #8470:
URL: https://github.com/apache/shardingsphere/issues/8470


   ## Bug Report
   
   **Exception**
   Caused by: java.time.format.DateTimeParseException: Text '2020-03-15 09:51:17.681' could not be parsed, unparsed text found at index 19
   	at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1952)
   	at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
   	at java.time.LocalDateTime.parse(LocalDateTime.java:492)
   
   
   **Location**
   org.apache.shardingsphere.sharding.algorithm.sharding.datetime.AutoIntervalShardingAlgorithm#parseDate
   
   **Reason**
   The parameter type of this method may be java.sql.Timestamp, directly calling the toString method will get milliseconds (like 2020-12-01 01:01:55.601), LocalDateTime uses yyyy-MM-dd HH:mm:ss, this Exceptions will be thrown.
   


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #8470:
URL: https://github.com/apache/shardingsphere/issues/8470#issuecomment-740363883


   Hi @chenjipdc Thanks for your response.
   Do you think it is possible to merge your code clip to the relevant module of ShardingSphere by a PR?


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #8470:
URL: https://github.com/apache/shardingsphere/issues/8470#issuecomment-737632187


   Hi @chenjipdc ,
   
   > Text '2020-03-15 09:51:17.681'
   
   Is it from the user's input? Web service? Will you keep that DateTime pattern in the database?
   
   > The parameter type of this method may be java.sql.Timestamp
   
   I suppose your reason is reasonable. Do you have any idea to solve this issue?


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
tuohai666 commented on issue #8470:
URL: https://github.com/apache/shardingsphere/issues/8470#issuecomment-737049575


   Hi, please fill in the template.
   ```
   
   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more details. 
   If no response anymore and we cannot reproduce it on current information, we will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   
   ### Expected behavior
   
   ### Actual behavior
   
   ### Reason analyze (If you can)
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   ### Example codes for reproduce this issue (such as a github link).
   
   ```


----------------------------------------------------------------
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



[GitHub] [shardingsphere] RaigorJiang closed issue #8470: DateTimeParseException

Posted by GitBox <gi...@apache.org>.
RaigorJiang closed issue #8470:
URL: https://github.com/apache/shardingsphere/issues/8470


   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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



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

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #8470:
URL: https://github.com/apache/shardingsphere/issues/8470#issuecomment-927243662


   Since this issue has been inactive for more than 6 months, we will close it. 
   If you still have related questions, please submit a new issue, thank you. 
   
   In addition, the support of DateTime in 5.0 has been greatly improved, welcome to try the new version.


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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



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

Posted by GitBox <gi...@apache.org>.
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