Your code is wrong:

 sixMonthsLater.getMonthOfYear() + "/" +
sixMonthsLater.getDayOfWeek() + "/" + sixMonthsLater.getYear();

should be getDayOfMonth()

Stephen



On 1 April 2010 20:09, J.V. <jvsr...@gmail.com> wrote:
> I have a date in string format like "MM/dd/YYYY" and I need to get a
> date in string format that is six months later.
>
> So here is my method:
>
>       String dateStr = "03/12/2010"
>
>       // Create a java.util.Date from dateStr
>       java.util.Date date = format.parse(dateStr);        DateTime
> dateTime = new DateTime(date);  // get a DateTime object
>       DateTime sixMonthsLater = dateTime.plusMonths(6);
>
>
>         sixMonthsLaterStr =  sixMonthsLater.getMonthOfYear() + "/" +
> sixMonthsLater.getDayOfWeek() + "/" + sixMonthsLater.getYear();
>
>       return sixMonthsLaterStr;
>
>
> When this run, I get a date back of (for sixMonthsLaterStr) as
> "9/7/2010" or September 7th, 2010 (I expected September 12th, 2010)
>
> so it is not quite six months later.  I would expect 3/12/2010 six
> months later would be 9/12/2010.
>
> can this bug be fixed? am I doing this right?  Why do I get a date of
> "9/7/2010" for six months beyond "3/12/2010" ??
>
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Joda-interest mailing list
> Joda-interest@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to