Github user tarekauel commented on the pull request:

    https://github.com/apache/spark/pull/6981#issuecomment-116881285
  
    @Davies
    
    To be honest, I don't think that this is precise enough, is it? Someday 
someone will create a Jira ticket and report the "bug" below:
    ```
    scala> 1970 + ((new 
java.text.SimpleDateFormat("yyyy-MM-dd").parse("2015-01-01").getTime - 1)/ 1000 
/ 3600 / 24 / 365.24).toInt
    res1: Int = 2015
    ```
    
    ```
    scala> val c = java.util.Calendar.getInstance(); c.setTimeInMillis(new 
java.text.SimpleDateFormat("yyyy-MM-dd").parse("2015-01-01").getTime - 1)
    
    scala> c.get(java.util.Calendar.YEAR)
    res6: Int = 2014
    ```
    
    I changed the coding in order to use `java.util.Calendar`. I compared the 
runtime for calculating the month 1,000,000 times:
    
    `sdf 1791ms`
    `calendar 251ms`
    
    This is significant faster.
    
    I created in a small prototype a custom implementation (without any Date 
functions and it was just as fast as `Calendar`



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