How do I convert year and week to Java date objects?

How do I convert year and week to Java date objects? I'm using jodatime, but it's also good to use the standard Java classes of the solution

Solution

Solutions using standard Java classes This simply takes the current time and sets the year and week fields to known values

Calendar cld = Calendar.getInstance();
cld.set(Calendar.YEAR,year);
cld.set(Calendar.WEEK_OF_YEAR,week);
Date result = cld.getTime();
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>