If a date is specified as a YearMonthDay, is there some way to determine the dates for the beginning and end of that week?
For example 2006-11-09 is a Thursday. The beginning of the week using the Gregorian chronology is Monday 2006-11-06 and the end of the week is Sunday 2006-11-12. My question is how would I derive 2006-11-06 (the start of the week) and 2006-11-12 (the end of the week) given 2006-11-09 (or any of 2006-11-06 to 2006-11-12)? What I had planned on doing was to first figure out the day of the week that the given date fell on. Once I know what day of the week it is, I can figure out how many days it is after Monday and before Sunday. Then I can generate the date for the Monday and Sunday by creating a new YearMonthDay from the given YearMonthDay and offsetting by a Period of the given number of days. However I can't figure out how to get the given dates day of the week as an integer. The closest I can seem to get is the following: YearMonthDay ymd; ymd = new YearMonthDay(2006, 11, 9); X = ymd.getChronology().dayOfWeek(); This gives the day of the week as a DateTimeField but there doesn't seem to be a way to determine what day of the week that DateTimeField actually is. The only int values I can seem to get from the DateTimeField (X) are getMaximumValue() and getMinimumValue(), but these don't help figure out what the current value of the field is. There does not appear to be any getValue() method that returns an int. There are constants in DateTimeConstants for MONDAY, TUESDAY, ... and SUNDAY which are of type int. There don't seem to be any constants for the days of the week that are DateTimeFields. Am I on the right track? Did I miss some method that makes this easy? Can someone offer a simple solution? Neil. ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Joda-interest mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/joda-interest
