Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 79798 invoked from network); 3 Aug 2003 23:55:22 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 3 Aug 2003 23:55:22 -0000 Received: (qmail 18856 invoked by uid 97); 3 Aug 2003 23:58:04 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 18849 invoked from network); 3 Aug 2003 23:58:03 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 3 Aug 2003 23:58:03 -0000 Received: (qmail 79292 invoked by uid 500); 3 Aug 2003 23:55:17 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 79281 invoked from network); 3 Aug 2003 23:55:17 -0000 Received: from unknown (HELO mail.lokitech.com) (216.7.13.68) by daedalus.apache.org with SMTP; 3 Aug 2003 23:55:17 -0000 Received: from 216.181.165.36 ([216.181.165.36]) by mail.lokitech.com (JAMES SMTP Server 2.1.3) with SMTP ID 960 for ; Sun, 3 Aug 2003 19:54:25 -0400 (EDT) Message-ID: <3F2DA0B1.2040204@lokitech.com> Date: Sun, 03 Aug 2003 19:54:25 -0400 From: Serge Knystautas User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030723 Thunderbird/0.1a X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jakarta Commons Developers List Subject: Re: [lang] DateUtils round and truncate functionality with Calendar.AM_PM References: <001101c35a19$5c534870$6f00a8c0@YellowJacket> In-Reply-To: <001101c35a19$5c534870$6f00a8c0@YellowJacket> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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. sergek@lokitech.com --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org