[lang] DateUtils round and truncate functionality with Calendar.AM_PM

2003-08-03 Thread Steven Caswell
Does anyone  know how the DateUtils methods round and truncate are suppose
to behave when passed Calendar.AM_PM? I've tried several combinations of
round, and they all seem to truncate instead. There is nothing in the
Javadocs for these methods about the expected result, and I'm not able to
tell if the methods are working properly.


Steven Caswell
[EMAIL PROTECTED]
In our own native land, in defense of the freedom that is our birthright,
and which we ever enjoyed till the late violation of it -- for the
protection of our property, acquired solely by the honest industry of our
fore-fathers and ourselves, against violence actually offered, we have taken
up arms. We shall lay them down when hostilities shall cease on the part of
the aggressors, and all danger of their being renewed shall be removed, and
not before. - Thomas Jefferson 




Re: [lang] DateUtils round and truncate functionality with Calendar.AM_PM

2003-08-03 Thread Stephen Colebourne
I don't know what it should do offhand. Perhaps you could suggest sensible
behaviour?

Stephen

- Original Message -
From: Steven Caswell [EMAIL PROTECTED]
Does anyone  know how the DateUtils methods round and truncate are suppose
to behave when passed Calendar.AM_PM? I've tried several combinations of
round, and they all seem to truncate instead. There is nothing in the
Javadocs for these methods about the expected result, and I'm not able to
tell if the methods are working properly.


Steven Caswell
[EMAIL PROTECTED]
In our own native land, in defense of the freedom that is our birthright,
and which we ever enjoyed till the late violation of it -- for the
protection of our property, acquired solely by the honest industry of our
fore-fathers and ourselves, against violence actually offered, we have taken
up arms. We shall lay them down when hostilities shall cease on the part of
the aggressors, and all danger of their being renewed shall be removed, and
not before. - Thomas Jefferson





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [lang] DateUtils round and truncate functionality with Calendar.AM_PM

2003-08-03 Thread Steven Caswell
I don't know that rounding to AM_PM makes sense. I'm having a difficult time
coming up with any rounding scenario that makes sense. I think it makes
sense to say that the boundary is 12:00PM, and that times before that value
cause round down, and times after that value cause round up.

But what does round down mean? What does round up mean? Maybe someone
who has a use case for this functionality can provide a good suggestion.

Steven Caswell
[EMAIL PROTECTED]
a.k.a Mungo Knotwise of Michel Delving
One ring to rule them all, one ring to find them...


 -Original Message-
 From: Stephen Colebourne [mailto:[EMAIL PROTECTED] 
 Sent: Sunday, August 03, 2003 6:32 PM
 To: Jakarta Commons Developers List; [EMAIL PROTECTED]
 Subject: Re: [lang] DateUtils round and truncate 
 functionality with Calendar.AM_PM
 
 
 I don't know what it should do offhand. Perhaps you could 
 suggest sensible behaviour?
 
 Stephen
 
 - Original Message -
 From: Steven Caswell [EMAIL PROTECTED]
 Does anyone  know how the DateUtils methods round and 
 truncate are suppose to behave when passed Calendar.AM_PM? 
 I've tried several combinations of round, and they all seem 
 to truncate instead. There is nothing in the Javadocs for 
 these methods about the expected result, and I'm not able to 
 tell if the methods are working properly.
 
 
 Steven Caswell
 [EMAIL PROTECTED]
 In our own native land, in defense of the freedom that is 
 our birthright, and which we ever enjoyed till the late 
 violation of it -- for the protection of our property, 
 acquired solely by the honest industry of our fore-fathers 
 and ourselves, against violence actually offered, we have 
 taken up arms. We shall lay them down when hostilities shall 
 cease on the part of the aggressors, and all danger of their 
 being renewed shall be removed, and not before. - Thomas Jefferson
 
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [lang] DateUtils round and truncate functionality with Calendar.AM_PM

2003-08-03 Thread Serge Knystautas
Steven Caswell wrote:
I don't know that rounding to AM_PM makes sense. I'm having a difficult time
coming up with any rounding scenario that makes sense. I think it makes
sense to say that the boundary is 12:00PM, and that times before that value
cause round down, and times after that value cause round up.
But what does round down mean? What does round up mean? Maybe someone
who has a use case for this functionality can provide a good suggestion.
Here's how I approached most of this logic... I treated truncating and 
rounding functions as eliminating all units below this order of specificity.

How to apply this to AM_PM?  Well, you'd keep the day unit and drop the 
hours unit.  So aside from the date, the two possible values are:
AM, 0 hours, 0 minutes, 0 sec, 0 ms.
PM, 0 hours, 0 minutes, 0 sec, 0 ms.

The first case is somewhat straight-forward... 0 hour is equivalent to 
12:00 AM.  The second case is a bit more confusing, but to be parallel, 
I would say it should be 12:00 PM.

So truncating would have 12:00 AM to 11:59:59.999 AM - 12:00 AM, and 
12:00 PM to 11:59:59.999 PM - 12:00 PM.  Rounding would then have 6:00 
PM to 5:59:59.999 AM - 12:00 AM and 6:00 AM to 5:59:59.999 PM - 12:00 
PM.  (I believe our convention is to always round up, so 6:00 AM - 
12:00 PM).

Does this make sense?  Probably not a very commonly used case, but seems 
like we should have predictable behavior is someone passes this unit. 
Or conversely it could throw an exception with an unanticipated time unit?

--
Serge Knystautas
President
Lokitech  software . strategy . design  http://www.lokitech.com/
p. 1.301.656.5501
e. [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: [lang] DateUtils round and truncate functionality with Calendar.AM_PM

2003-08-03 Thread Stephen Colebourne
Best guess:

roundDown 01:30 goes to 00:00
roundUp  01:30 goes to 12:00
roundDown 13:30 goes to 12:00
roundUp  13:30 goes to 00:00 next day

Stephen

- Original Message -
From: Steven Caswell [EMAIL PROTECTED]
To: 'Jakarta Commons Developers List' [EMAIL PROTECTED]
Sent: Monday, August 04, 2003 12:45 AM
Subject: RE: [lang] DateUtils round and truncate functionality with
Calendar.AM_PM


 I don't know that rounding to AM_PM makes sense. I'm having a difficult
time
 coming up with any rounding scenario that makes sense. I think it makes
 sense to say that the boundary is 12:00PM, and that times before that
value
 cause round down, and times after that value cause round up.

 But what does round down mean? What does round up mean? Maybe someone
 who has a use case for this functionality can provide a good suggestion.

 Steven Caswell
 [EMAIL PROTECTED]
 a.k.a Mungo Knotwise of Michel Delving
 One ring to rule them all, one ring to find them...


  -Original Message-
  From: Stephen Colebourne [mailto:[EMAIL PROTECTED]
  Sent: Sunday, August 03, 2003 6:32 PM
  To: Jakarta Commons Developers List; [EMAIL PROTECTED]
  Subject: Re: [lang] DateUtils round and truncate
  functionality with Calendar.AM_PM
 
 
  I don't know what it should do offhand. Perhaps you could
  suggest sensible behaviour?
 
  Stephen
 
  - Original Message -
  From: Steven Caswell [EMAIL PROTECTED]
  Does anyone  know how the DateUtils methods round and
  truncate are suppose to behave when passed Calendar.AM_PM?
  I've tried several combinations of round, and they all seem
  to truncate instead. There is nothing in the Javadocs for
  these methods about the expected result, and I'm not able to
  tell if the methods are working properly.
 
 
  Steven Caswell
  [EMAIL PROTECTED]
  In our own native land, in defense of the freedom that is
  our birthright, and which we ever enjoyed till the late
  violation of it -- for the protection of our property,
  acquired solely by the honest industry of our fore-fathers
  and ourselves, against violence actually offered, we have
  taken up arms. We shall lay them down when hostilities shall
  cease on the part of the aggressors, and all danger of their
  being renewed shall be removed, and not before. - Thomas Jefferson
 
 
 
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 



 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]