Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8396#discussion_r38078235
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
 ---
    @@ -107,30 +107,21 @@ object DateTimeUtils {
       }
     
       def stringToTime(s: String): java.util.Date = {
    -    if (!s.contains('T')) {
    +    var indexOfGMT = s.indexOf("GMT");
    +    if (indexOfGMT != -1) {
    +      // timezone with ISO8601
    +      val s0 = s.substring(0, indexOfGMT)
    +      val s1 = s.substring(indexOfGMT + 3)
    +      return stringToTime(s0 + s1)
    +    } else if (!s.contains('T')) {
           // JDBC escape string
           if (s.contains(' ')) {
             Timestamp.valueOf(s)
           } else {
             Date.valueOf(s)
           }
    -    } else if (s.endsWith("Z")) {
    -      // this is zero timezone of ISO8601
    -      stringToTime(s.substring(0, s.length - 1) + "GMT-00:00")
    -    } else if (s.indexOf("GMT") == -1) {
    -      // timezone with ISO8601
    -      val inset = "+00.00".length
    -      val s0 = s.substring(0, s.length - inset)
    -      val s1 = s.substring(s.length - inset, s.length)
    -      if (s0.substring(s0.lastIndexOf(':')).contains('.')) {
    -        stringToTime(s0 + "GMT" + s1)
    -      } else {
    -        stringToTime(s0 + ".0GMT" + s1)
    -      }
         } else {
    -      // ISO8601 with GMT insert
    -      val ISO8601GMT: SimpleDateFormat = new SimpleDateFormat( 
"yyyy-MM-dd'T'HH:mm:ss.SSSz" )
    -      ISO8601GMT.parse(s)
    +      javax.xml.bind.DatatypeConverter.parseDateTime(s).getTime()
    --- End diff --
    
    OK, that's guaranteed by the method in the sense that XML dates must be in 
ISO8601 format? Do we have tests for this?
    
    Nits: import `DatatypeConverter` and I think you can avoid the `return` 
keyword in the code you added, for consistency.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to