Introducing the week with Joda-Time

What is the best way to present the week of the year using the Joda-Time library? I look something as elegant as YearMonthto represent the month of the year.

+5
source share
2 answers

After some searching, I found a solution using the class Partialfor this problem.

Partial yearWeek = new Partial(
                   new DateTimeFieldType[] {DateTimeFieldType.weekyear(), 
                                            DateTimeFieldType.weekOfWeekyear()}, 
                                            new int[] {year, week});
+5
source

TL; DR

org.threeten.extra.YearWeek.of( 2018 , 28 ) 

java.time

The Joda-Time project is now in maintenance mode , with the team advising switching to the java.time classes .

org.threeten.extra.YearWeek

The java.time classes are extended by ThreeTen-Extra . This project includes a class YearWeek, just what you need.

, "" . , ISO 8601 , № 1 , . , 52 53 . / .

.

YearWeek yw = YearWeek.of( 2018 , 7 ) ;

, DayOfWeek enum.

LocalDate wednesdayOf2018W07 = yw.atDay( DayOfWeek.THURSDAY ) ;

java.time

java.time Java 8 . legacy -, java.util.Date, Calendar SimpleDateFormat.

Joda-Time, , java.time.

, . Oracle. Qaru . JSR 310.

java.time?

ThreeTen-Extra java.time . java.time. , Interval, YearWeek, YearQuarter .

+1

All Articles