About Question enthuware.ocajp.i.v8.2.1430 :
Moderator: admin
-
- Posts: 29
- Joined: Sun Apr 05, 2015 11:26 am
- Contact:
About Question enthuware.ocajp.i.v8.2.1430 :
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...
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...
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1430 :
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.
If you like our products and services, please help us by posting your review here.
-
- Posts: 29
- Joined: Sun Apr 05, 2015 11:26 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1430 :
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
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
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1430 :
Your formatter is for date+time but you are trying to parse a string that contains only date.
If you like our products and services, please help us by posting your review here.
-
- Posts: 29
- Joined: Sun Apr 05, 2015 11:26 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1430 :
Hi,
Thank you, I did not realize that
I'll try again using only the date formatter.
Thank you, I did not realize that
I'll try again using only the date formatter.
-
- Posts: 6
- Joined: Mon Feb 01, 2016 3:13 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1430 :
Is this person real, 'cause I rather not learn on something out-of-scope that is as captivating as this,Only one person reported getting a simple question on it.
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.
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1430 :
The person is certainly real.olograph wrote:Is this person real, 'Only one person reported getting a simple question on it.
Sure, that is a decision that you should make based on your bandwidth.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.
You can skip it but if I were you, I would spend may be about 10-15 minutes on it.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.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 7
- Joined: Tue Aug 22, 2017 11:13 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1430 :
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 ?
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 ?
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1430 :
No, the problem statement want to print the next Tuesday (not today even if today is a tuesday).
If you like our products and services, please help us by posting your review here.
-
- Posts: 28
- Joined: Mon Sep 25, 2017 8:16 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1430 :
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 lowercase is the correct one for parsing above String: y = year-of-era
-
- Posts: 202
- Joined: Mon Apr 02, 2018 8:40 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1430 :
Are TemporalAdjusters relevant for the exam? The answer about this is 4 years old.
Have there been any recent reports of people getting it?
Have there been any recent reports of people getting it?
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1430 :
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.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 43 guests