I got it working again using the code provided by Stephen. The looping was my mistake.
Thanks -----Original Message----- From: Jason Roscoe [mailto:jros...@riteaid.com] Sent: Wednesday, September 22, 2010 7:30 AM To: Discussion of the Joda project Subject: Re: [Joda-interest] previous date Stephen, I changed your "while" to an "if" because with your code, it get's stuck in a loop, and never returns. Any suggestions on how to fix that? Thanks!!! -----Original Message----- From: Jason Roscoe [mailto:jros...@riteaid.com] Sent: Tuesday, September 21, 2010 3:52 PM To: Discussion of the Joda project Subject: Re: [Joda-interest] previous date The code that you gave only gives me 1 day previous, so if I try the below, which sets today's date to 2010-10-01, it is returning to me 2010-09-30, which is 1 day previous. LocalDate today = new LocalDate(2010, 10, 01); //this is a Friday LocalDate circularLinkDate = null; if (today.getDayOfWeek() != DateTimeConstants.TUESDAY) { circularLinkDate = today.minusDays(1); } else { circularLinkDate = today; } return circularLinkDate; So, this logic is still not correct. Any help is greatly appreciated!! -----Original Message----- From: Stephen Colebourne [mailto:scolebou...@joda.org] Sent: Tuesday, September 21, 2010 10:10 AM To: Discussion of the Joda project Subject: Re: [Joda-interest] previous date No. The previous Tuesday to a Wednesday is the day before. By subtracting a week, you'll end up 8 days earllier. I suggest writing a little unit test and experimenting to understand what the methods do if the javadoc isn't clear enough. Stephen On 21 September 2010 06:59, Jason Roscoe <jros...@riteaid.com> wrote: > Would this work (including if the previous Tuesday was in a previous month): > > DateTime previousTuesday = new DateTime().minusWeeks(1).withDayOfWeek(2); > > -----Original Message----- > From: Stephen Colebourne [mailto:scolebou...@joda.org] > Sent: Tuesday, September 21, 2010 9:56 AM > To: Discussion of the Joda project > Subject: Re: [Joda-interest] previous date > > LocalDate d = new LocalDate(2010, 9, 20); > while (d.getDayOfWeek() != DateTimeConstants.TUESDAY) { > d = d.minusDays(1); > } > > > On 21 September 2010 02:48, Jason Roscoe <jros...@riteaid.com> wrote: >> Could someone share some code example to do this? >> >> Thanks >> >> On Sep 21, 2010, at 1:25 AM, "Stephen Colebourne" <scolebou...@joda.org> >> wrote: >> >>> In Joda-Time you will need to loop backwards, calling minusDays(1) >>> each time around the loop, in order to find the day of week. >>> Stephen >>> >>> On 20 September 2010 12:51, Jason Roscoe <jros...@riteaid.com> wrote: >>>> I need to take the current date, and figure out the date for a previous >>>> day, >>>> for example Tuesday. So if today is Monday, Sept. 20, I need to return the >>>> previous Tuesday's date of September 14. How can I do this with joda time >>>> in the format yyyy-mm-dd (Ex.: 2010-09-14)? >>>> >>>> >>>> >>>> Thanks! >>>> >>>> ________________________________ >>>> Disclaimer: This e-mail message is intended only for the personal use of >>>> the recipient(s) named above. If you are not an intended recipient, you >>>> may not review, copy or distribute this message. If you have received this >>>> communication in error, please notify us immediately by e-mail and delete >>>> the original message. >>>> >>>> This e-mail expresses views only of the sender, which are not to be >>>> attributed to Rite Aid Corporation and may not be copied or distributed >>>> without this statement. >>>> >>>> ------------------------------------------------------------------------------ >>>> Start uncovering the many advantages of virtual appliances >>>> and start using them to simplify application deployment and >>>> accelerate your shift to cloud computing. >>>> http://p.sf.net/sfu/novell-sfdev2dev >>>> _______________________________________________ >>>> Joda-interest mailing list >>>> Joda-interest@lists.sourceforge.net >>>> https://lists.sourceforge.net/lists/listinfo/joda-interest >>>> >>>> >>> >>> ------------------------------------------------------------------------------ >>> Start uncovering the many advantages of virtual appliances >>> and start using them to simplify application deployment and >>> accelerate your shift to cloud computing. >>> http://p.sf.net/sfu/novell-sfdev2dev >>> _______________________________________________ >>> Joda-interest mailing list >>> Joda-interest@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/joda-interest >> >> Disclaimer: This e-mail message is intended only for the personal use of >> the recipient(s) named above. If you are not an intended recipient, you >> may not review, copy or distribute this message. If you have received this >> communication in error, please notify us immediately by e-mail and delete >> the original message. >> >> This e-mail expresses views only of the sender, which are not to be >> attributed to Rite Aid Corporation and may not be copied or distributed >> without this statement. >> >> ------------------------------------------------------------------------------ >> Start uncovering the many advantages of virtual appliances >> and start using them to simplify application deployment and >> accelerate your shift to cloud computing. >> http://p.sf.net/sfu/novell-sfdev2dev >> _______________________________________________ >> Joda-interest mailing list >> Joda-interest@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/joda-interest >> > > ------------------------------------------------------------------------------ > Start uncovering the many advantages of virtual appliances > and start using them to simplify application deployment and > accelerate your shift to cloud computing. > http://p.sf.net/sfu/novell-sfdev2dev > _______________________________________________ > Joda-interest mailing list > Joda-interest@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/joda-interest > > Disclaimer: This e-mail message is intended only for the personal use of > the recipient(s) named above. If you are not an intended recipient, you > may not review, copy or distribute this message. If you have received this > communication in error, please notify us immediately by e-mail and delete > the original message. > > This e-mail expresses views only of the sender, which are not to be > attributed to Rite Aid Corporation and may not be copied or distributed > without this statement. > > ------------------------------------------------------------------------------ > Start uncovering the many advantages of virtual appliances > and start using them to simplify application deployment and > accelerate your shift to cloud computing. > http://p.sf.net/sfu/novell-sfdev2dev > _______________________________________________ > Joda-interest mailing list > Joda-interest@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/joda-interest > ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ Joda-interest mailing list Joda-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/joda-interest Disclaimer: This e-mail message is intended only for the personal use of the recipient(s) named above. If you are not an intended recipient, you may not review, copy or distribute this message. If you have received this communication in error, please notify us immediately by e-mail and delete the original message. This e-mail expresses views only of the sender, which are not to be attributed to Rite Aid Corporation and may not be copied or distributed without this statement. ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ Joda-interest mailing list Joda-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/joda-interest Disclaimer: This e-mail message is intended only for the personal use of the recipient(s) named above. If you are not an intended recipient, you may not review, copy or distribute this message. If you have received this communication in error, please notify us immediately by e-mail and delete the original message. This e-mail expresses views only of the sender, which are not to be attributed to Rite Aid Corporation and may not be copied or distributed without this statement. ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ Joda-interest mailing list Joda-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/joda-interest Disclaimer: This e-mail message is intended only for the personal use of the recipient(s) named above. If you are not an intended recipient, you may not review, copy or distribute this message. If you have received this communication in error, please notify us immediately by e-mail and delete the original message. This e-mail expresses views only of the sender, which are not to be attributed to Rite Aid Corporation and may not be copied or distributed without this statement. ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ Joda-interest mailing list Joda-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/joda-interest