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

    https://github.com/apache/spark/pull/8396#discussion_r37761954
  
    --- 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 --
    
    This might bear explanation -- why does it implementing parsing correctly 
and why is GMT special-cased?


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to