Some of what you desire is probably achievable via the rounding methods 
on the property objects:

rounded = dateTime.halfDay().roundFloor();

Stephen


J. Matthew Pryor wrote:
> There is lots of email in the archive that seems similar to my  
> question, but AFAICT none that addresses it directly.
> 
> I want to be able to round any given Instant to the nearest Period to  
> support grouping of data.
> 
> i.e. someone might want to group by 2 week periods, so given an  
> Instant, I want to be able to work out the nearest instant (before or  
> after) on the period boundary where "now" is considered to be the end  
> of the current period. If today is Tuesday, then consider that this 2  
> week Period ends this week. Given any date (from now backward) I'd  
> like to calculate the "2 week Period" that it fits in to.
> 
> // pseudo code
> 
> Period sevenDays = Days.SEVEN;
> 
> Instant nearestWeek = sevenDays.roundToNearest(new DateTime());
> 
> Period twelveHours = Hours.hours(12);
> 
> Instant nearestHalfDay = twelveHours.roundToNearest(new DateTime());
> 
> 
> I hope that makes sense, any help or pointers greatly appreciated
> 
> Matthew
> 
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Joda-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
> 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Joda-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to