You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Dan Checkoway (JIRA)" <ji...@apache.org> on 2010/03/04 16:18:27 UTC

[jira] Created: (LANG-598) DateUtils.isSameDay needs to factor in TimeZone

DateUtils.isSameDay needs to factor in TimeZone
-----------------------------------------------

                 Key: LANG-598
                 URL: https://issues.apache.org/jira/browse/LANG-598
             Project: Commons Lang
          Issue Type: Improvement
          Components: lang.time.*
    Affects Versions: 2.5
            Reporter: Dan Checkoway


DateUtils.isSameDay works great as long as you only care about the default system TimeZone.  If you're trying to see if two Dates are the same day in *another* TimeZone, then you're hosed.

For example, let's say the two dates being compared are:

January 1, 2010 at 8:30pm PST
January 1, 2010 at 9:30pm PST

If your system TimeZone is PST, then sure, those two dates are on the "same day."  But they are NOT the same day in EST, for example.

The fix would be simple.  Add an isSameDay(Date, Date, TimeZone) method, and simply call setTimezone on each of the Calendar objects constructed.

The isSameDay(Calendar, Calendar) method can probably be left alone, since the caller conceivably has called setTimeZone on the Calendar objects prior to calling isSameDay.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-598) DateUtils.isSameDay needs to factor in TimeZone

Posted by "Shashi Kant Sharma (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12922018#action_12922018 ] 

Shashi Kant Sharma commented on LANG-598:
-----------------------------------------

Should we have an overloaded method of isSameDay(Date date1, Date date2) as well ?

> DateUtils.isSameDay needs to factor in TimeZone
> -----------------------------------------------
>
>                 Key: LANG-598
>                 URL: https://issues.apache.org/jira/browse/LANG-598
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.time.*
>    Affects Versions: 2.5
>            Reporter: Dan Checkoway
>             Fix For: 3.1
>
>
> DateUtils.isSameDay works great as long as you only care about the default system TimeZone.  If you're trying to see if two Dates are the same day in *another* TimeZone, then you're hosed.
> For example, let's say the two dates being compared are:
> January 1, 2010 at 8:30pm PST
> January 1, 2010 at 9:30pm PST
> If your system TimeZone is PST, then sure, those two dates are on the "same day."  But they are NOT the same day in EST, for example.
> The fix would be simple.  Add an isSameDay(Date, Date, TimeZone) method, and simply call setTimezone on each of the Calendar objects constructed.
> The isSameDay(Calendar, Calendar) method can probably be left alone, since the caller conceivably has called setTimeZone on the Calendar objects prior to calling isSameDay.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-598) DateUtils.isSameDay needs to factor in TimeZone

Posted by "Shashi Kant Sharma (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-598?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Shashi Kant Sharma updated LANG-598:
------------------------------------

    Comment: was deleted

(was: Should we have an overloaded method of isSameDay(Date date1, Date date2) as well ?)

> DateUtils.isSameDay needs to factor in TimeZone
> -----------------------------------------------
>
>                 Key: LANG-598
>                 URL: https://issues.apache.org/jira/browse/LANG-598
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.time.*
>    Affects Versions: 2.5
>            Reporter: Dan Checkoway
>             Fix For: 3.1
>
>
> DateUtils.isSameDay works great as long as you only care about the default system TimeZone.  If you're trying to see if two Dates are the same day in *another* TimeZone, then you're hosed.
> For example, let's say the two dates being compared are:
> January 1, 2010 at 8:30pm PST
> January 1, 2010 at 9:30pm PST
> If your system TimeZone is PST, then sure, those two dates are on the "same day."  But they are NOT the same day in EST, for example.
> The fix would be simple.  Add an isSameDay(Date, Date, TimeZone) method, and simply call setTimezone on each of the Calendar objects constructed.
> The isSameDay(Calendar, Calendar) method can probably be left alone, since the caller conceivably has called setTimeZone on the Calendar objects prior to calling isSameDay.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-598) DateUtils.isSameDay needs to factor in TimeZone

Posted by "Dan Checkoway (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12848070#action_12848070 ] 

Dan Checkoway commented on LANG-598:
------------------------------------

Good question!  Maybe the isSameDay(Calendar, Calendar) method should take a TimeZone argument to resolve that ambiguity.  That would probably make sense.  So in my opinion:

isSameDay(Date, Date) and isSameDay(Calendar, Calendar) could pass TimeZone.getDefault() to isSameDay(Date, Date, TimeZone) and isSameDay(Calendar, Calendar, TimeZone).

Does that seem reasonable?
(and thank you for looking into this)

> DateUtils.isSameDay needs to factor in TimeZone
> -----------------------------------------------
>
>                 Key: LANG-598
>                 URL: https://issues.apache.org/jira/browse/LANG-598
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.time.*
>    Affects Versions: 2.5
>            Reporter: Dan Checkoway
>             Fix For: 3.1
>
>
> DateUtils.isSameDay works great as long as you only care about the default system TimeZone.  If you're trying to see if two Dates are the same day in *another* TimeZone, then you're hosed.
> For example, let's say the two dates being compared are:
> January 1, 2010 at 8:30pm PST
> January 1, 2010 at 9:30pm PST
> If your system TimeZone is PST, then sure, those two dates are on the "same day."  But they are NOT the same day in EST, for example.
> The fix would be simple.  Add an isSameDay(Date, Date, TimeZone) method, and simply call setTimezone on each of the Calendar objects constructed.
> The isSameDay(Calendar, Calendar) method can probably be left alone, since the caller conceivably has called setTimeZone on the Calendar objects prior to calling isSameDay.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (LANG-598) DateUtils.isSameDay needs to factor in TimeZone

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LANG-598?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Yandell updated LANG-598:
-------------------------------

    Fix Version/s: 3.1

> DateUtils.isSameDay needs to factor in TimeZone
> -----------------------------------------------
>
>                 Key: LANG-598
>                 URL: https://issues.apache.org/jira/browse/LANG-598
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.time.*
>    Affects Versions: 2.5
>            Reporter: Dan Checkoway
>             Fix For: 3.1
>
>
> DateUtils.isSameDay works great as long as you only care about the default system TimeZone.  If you're trying to see if two Dates are the same day in *another* TimeZone, then you're hosed.
> For example, let's say the two dates being compared are:
> January 1, 2010 at 8:30pm PST
> January 1, 2010 at 9:30pm PST
> If your system TimeZone is PST, then sure, those two dates are on the "same day."  But they are NOT the same day in EST, for example.
> The fix would be simple.  Add an isSameDay(Date, Date, TimeZone) method, and simply call setTimezone on each of the Calendar objects constructed.
> The isSameDay(Calendar, Calendar) method can probably be left alone, since the caller conceivably has called setTimeZone on the Calendar objects prior to calling isSameDay.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (LANG-598) DateUtils.isSameDay needs to factor in TimeZone

Posted by "Srihari Reddy (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LANG-598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12848035#action_12848035 ] 

Srihari Reddy commented on LANG-598:
------------------------------------

so if the Calendar objects are in different time zones should the expected result be false or should it consider the time difference between the timezones

> DateUtils.isSameDay needs to factor in TimeZone
> -----------------------------------------------
>
>                 Key: LANG-598
>                 URL: https://issues.apache.org/jira/browse/LANG-598
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.time.*
>    Affects Versions: 2.5
>            Reporter: Dan Checkoway
>             Fix For: 3.1
>
>
> DateUtils.isSameDay works great as long as you only care about the default system TimeZone.  If you're trying to see if two Dates are the same day in *another* TimeZone, then you're hosed.
> For example, let's say the two dates being compared are:
> January 1, 2010 at 8:30pm PST
> January 1, 2010 at 9:30pm PST
> If your system TimeZone is PST, then sure, those two dates are on the "same day."  But they are NOT the same day in EST, for example.
> The fix would be simple.  Add an isSameDay(Date, Date, TimeZone) method, and simply call setTimezone on each of the Calendar objects constructed.
> The isSameDay(Calendar, Calendar) method can probably be left alone, since the caller conceivably has called setTimeZone on the Calendar objects prior to calling isSameDay.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.