Page 1 of 1
About Question enthuware.ocajp.i.v8.2.1430 :
Posted: Sat May 16, 2015 12:22 pm
by ElizabethCM
Hi,
The java.time.temporal.TemporalAdjusters are not mentioned in the book. Do you think they will be included in the material?
It's not bad to know them...but there are a lot of new things to remember about the dates...
Re: About Question enthuware.ocajp.i.v8.2.1430 :
Posted: Sat May 16, 2015 9:15 pm
by admin
Only one person reported getting a simple question on it. So I would say if you just go through our questions on this, you will be fine. No need to read further.
Re: About Question enthuware.ocajp.i.v8.2.1430 :
Posted: Sun May 17, 2015 9:51 am
by ElizabethCM
Hi,
Thank you for the quick answer. I will go through the exercises again.
I am struggling with the following code which appears in the book at page 149 (at least this is the page using Kindle Cloud Reader)
Could you please have a look at it?
DateTimeFormatter f = DateTimeFormatter.ofPattern("MM dd YYYY");
LocalDate date1 = LocalDate.parse("01 02 2015", f);
System.out.println(date1);
It gives the following error:
Exception in thread "main" java.time.format.DateTimeParseException: Text '01 02 2015' could not be parsed: Unable to obtain LocalDate from TemporalAccessor: {WeekBasedYear[WeekFields[SUNDAY,1]]=2015, MonthOfYear=1, DayOfMonth=2},ISO of type java.time.format.Parsed
at java.time.format.DateTimeFormatter.createError(Unknown Source)
at java.time.format.DateTimeFormatter.parse(Unknown Source)
at java.time.LocalDate.parse(Unknown Source)
at date_time.DateTimeFormat.main(DateTimeFormat.java:43)
Caused by: java.time.DateTimeException: Unable to obtain LocalDate from TemporalAccessor: {WeekBasedYear[WeekFields[SUNDAY,1]]=2015, MonthOfYear=1, DayOfMonth=2},ISO of type java.time.format.Parsed
at java.time.LocalDate.from(Unknown Source)
at java.time.LocalDate$$Lambda$14/1595428806.queryFrom(Unknown Source)
at java.time.format.Parsed.query(Unknown Source)
... 3 more
Do you have any idea why? Thanks
PS: I did not know if for questions like this (related only to a certain exercise by topic) I should start a new topic on the forum or just write here. Thanks
Re: About Question enthuware.ocajp.i.v8.2.1430 :
Posted: Sun May 17, 2015 11:38 am
by admin
Your formatter is for date+time but you are trying to parse a string that contains only date.
Re: About Question enthuware.ocajp.i.v8.2.1430 :
Posted: Tue May 19, 2015 2:43 pm
by ElizabethCM
Hi,
Thank you, I did not realize that

I'll try again using only the date formatter.
Re: About Question enthuware.ocajp.i.v8.2.1430 :
Posted: Mon Feb 15, 2016 10:36 pm
by olograph
Only one person reported getting a simple question on it.
Is this person real, 'cause I rather not learn on something out-of-scope that is as captivating as this,
especially at exam 6 of 7, having a TON of things currently in mind.
If you'd say it's one person out of 3000, I'd skip this topic so fast the page will have tire fire on it.
Re: About Question enthuware.ocajp.i.v8.2.1430 :
Posted: Mon Feb 15, 2016 10:43 pm
by admin
olograph wrote:Only one person reported getting a simple question on it.
Is this person real, '
The person is certainly real.
cause I rather not learn on something out-of-scope that is as captivating as this,
especially at exam 6 of 7, having a TON of things currently in mind.
Sure, that is a decision that you should make based on your bandwidth.
If you'd say it's one person out of 3000, I'd skip this topic so fast the page will have tire fire on it.
You can skip it but if I were you, I would spend may be about 10-15 minutes on it.
HTH,
Paul.
Re: About Question enthuware.ocajp.i.v8.2.1430 :
Posted: Sat Sep 02, 2017 1:49 pm
by hsiaok
The question is :
You want to print the date that represents upcoming tuesday from now even if the current day is a tuesday. Which of the following lines of code accomplishe(s) this?
Why is it using System.out.println(LocalDate.now().with(TemporalAdjusters.next(DayOfWeek.TUESDAY)));
Should it be
System.out.println(LocalDate.now().with(TemporalAdjusters.nextOrSame(DayOfWeek.TUESDAY))); ? because should return today if today is Tuesday ?
Re: About Question enthuware.ocajp.i.v8.2.1430 :
Posted: Sun Sep 03, 2017 9:46 pm
by admin
No, the problem statement want to print the next Tuesday (not today even if today is a tuesday).
Re: About Question enthuware.ocajp.i.v8.2.1430 :
Posted: Sun Oct 08, 2017 2:47 am
by JuergGogo
I am struggling with the following code which appears in the book at page 149 (at least this is the page using Kindle Cloud Reader)
Could you please have a look at it?
DateTimeFormatter f = DateTimeFormatter.ofPattern("MM dd YYYY");
LocalDate date1 = LocalDate.parse("01 02 2015", f);
System.out.println(date1);
Your formatter is for date+time but you are trying to parse a string that contains only date.
Code: Select all
import java.time.*;
import java.time.format.*;
public class TestClass{
public static void main(String[] args) {
// DateTimeFormatter f = DateTimeFormatter.ofPattern("MM dd YYYY"); //--> DateTimeParseException
DateTimeFormatter f = DateTimeFormatter.ofPattern("MM dd yyyy");
LocalDate date1 = LocalDate.parse("01 02 2015", f );
System.out.println( date1 );
}
}
"YYYY" in uppercase isn't working: Y = week-based-year
"yyyy" in lowercase is the correct one for parsing above String: y = year-of-era
Re: About Question enthuware.ocajp.i.v8.2.1430 :
Posted: Mon May 06, 2019 3:47 am
by flex567
Are TemporalAdjusters relevant for the exam? The answer about this is 4 years old.
Have there been any recent reports of people getting it?
Re: About Question enthuware.ocajp.i.v8.2.1430 :
Posted: Mon May 06, 2019 5:36 am
by admin
No, but I would still go though the information given in this question. You might be the lucky/unlucky one who gets that one question.