Period ppw = Period.parse("p2w");
Period ppW = Period.parse("P10W");
Period ppy = Period.parse("p10y2m6w12d");
System.out.println("\n"+ppw+" "+ppW+" "+ppy);
In the above test all the weeks were automatically converted to days when printed. So has something changed in JVM, or the phrase in the book is not referring to the results?
Last line of the first paragraph under "Parsing a string to create a Period" heading.
You mean, "For example, P1Y10M3d means 1 year, 10 months, and 3 days, P1Y3D means 1 year and 3 days. p1Y2w means 1 year and 2 weeks"? It is correct. It is talking about what these specification strings imply. i.e. y is for years, d is for days, m is for months, and w is for weeks.
It is not talking about how the Period object gets printed. Should be made clear.
If you like our products and services, please help us by posting your review here.
The Javadoc says, "The supported units of a period are YEARS, MONTHS and DAYS." Only the API designers can answer why they decided not to support WEEKS as well. I don't remember coming across any reason for this.
If you want to print weeks, you need to get days and divide by 7. There is no getWeeks method in Period.
If you like our products and services, please help us by posting your review here.
Apparently, there may be differences? Does the exam expect us to know these differences?
Example:
ISO_LOCAL_DATE ISO Local Date '2011-12-03'
ISO_DATE ISO Date with or without offset '2011-12-03+01:00'; '2011-12-03')