Create a date with week and year

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Create a date with week and year

redfox26
Hi

i try to create a date with only the week and the year.

DateTime dt = new DateTime();
dt.withWeekyear(29);
dt.withYear(2011);
           
System.out.println("dt " +  dt.getWeekyear()+ " " + dt.getYear());

i get: dt 2012 2012

System.out.println("dt " +  dt.getWeekOfWeekyear()+ " " + dt.getYear());

i get: dt 16 2012


is there a way to get: 29 2011?

thanks

------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Create a date with week and year

jodastephen
With week based years you should ensure that the methods used are
consistent - week-of-weekyear is measured within a weekyear.

Shouldn't you be using:
DateTime dt = new DateTime();
dt.withWeekOfWeekyear(29);
dt.withWeekyear(2011);

Stephen

On 21 April 2012 09:07, redfox26 <[hidden email]> wrote:

> Hi
>
> i try to create a date with only the week and the year.
>
> DateTime dt = new DateTime();
> dt.withWeekyear(29);
> dt.withYear(2011);
>
> System.out.println("dt " +  dt.getWeekyear()+ " " + dt.getYear());
>
> i get: dt 2012 2012
>
> System.out.println("dt " +  dt.getWeekOfWeekyear()+ " " + dt.getYear());
>
> i get: dt 16 2012
>
>
> is there a way to get: 29 2011?
>
> thanks
>
> ------------------------------------------------------------------------------
> For Developers, A Lot Can Happen In A Second.
> Boundary is the first to Know...and Tell You.
> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
> http://p.sf.net/sfu/Boundary-d2dvs2
> _______________________________________________
> Joda-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/joda-interest

------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Joda-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/joda-interest
Loading...