About Question enthuware.ocajp.i.v8.2.1484 :
Moderator: admin
-
- Posts: 4
- Joined: Mon Jul 20, 2015 1:47 pm
- Contact:
About Question enthuware.ocajp.i.v8.2.1484 :
Hi everyone,
Do you have any recommendations for a book that has well coverage for the new Date and Time API?
Thanks in advance.
Regards,
Islam Amin
Do you have any recommendations for a book that has well coverage for the new Date and Time API?
Thanks in advance.
Regards,
Islam Amin
-
- Site Admin
- Posts: 10113
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1484 :
Oracle's Date and Time API summary is the best for exam purpose: https://docs.oracle.com/javase/8/docs/a ... mmary.html
Also, go through the descriptions of the important classes (Listed on the page mentioned above).
Also, go through the descriptions of the important classes (Listed on the page mentioned above).
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.1484 :
Code: Select all
import java.time.*;
public class TestClass {
public static void main(String[] args) {
LocalDateTime ld = LocalDateTime.of(2017, Month.OCTOBER, 28, 10, 0);
ZonedDateTime date = ZonedDateTime.of(ld, ZoneId.of("Europe/Paris"));
date = date.plus(Duration.ofDays(1));
System.out.println(ld); // 2017-10-28T10:00
System.out.println(date); // 2017-10-29T09:00+01:00[Europe/Paris]
date = ZonedDateTime.of(ld, ZoneId.of("Europe/Paris"));
date = date.plus(Period.ofDays(1));
System.out.println(ld); // 2017-10-28T10:00
System.out.println(date); // 2017-10-29T10:00+01:00[Europe/Paris]
}
}
It's the opposite, no? Duration adapts time to DST and Period is fix 24h?Durations and periods differ in their treatment of daylight savings time when added to ZonedDateTime. A Duration will add an exact number of seconds, thus a duration of one day is always exactly 24 hours. By contrast, a Period will add a conceptual day, trying to maintain the local time.
-
- Site Admin
- Posts: 10113
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1484 :
No, check this article by Oracle: https://docs.oracle.com/javase/tutorial ... eriod.html
It explains the difference between Duration and Period.
It explains the difference between Duration and Period.
If you like our products and services, please help us by posting your review here.
-
- Posts: 1
- Joined: Tue Nov 07, 2017 8:10 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1484 :
Here is a bug in test.
I live not in US, so I do not need to know then US people changes time to winter.
It is stupid.
No body cears about US time in my country.
I live not in US, so I do not need to know then US people changes time to winter.
It is stupid.
No body cears about US time in my country.
-
- Site Admin
- Posts: 10113
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1484 :
well, what if you are working on an application that is used all over the world
If you like our products and services, please help us by posting your review here.
-
- Posts: 3
- Joined: Sat Oct 20, 2018 7:14 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1484 :
Hi,
please why this is the correct one?
2015-11-01T09:00-05:00[US/Eastern]
2015-11-01T10:00-05:00[US/Eastern]
I have chosen this one :
2015-11-01T10:00-05:00[US/Eastern]
2015-11-01T10:00-05:00[US/Eastern]
Duration.ofDays(1) is 24h
Period.ofDays(1) is 1 day
For me, they are the same? what I'm missing here? thanks
please why this is the correct one?
2015-11-01T09:00-05:00[US/Eastern]
2015-11-01T10:00-05:00[US/Eastern]
I have chosen this one :
2015-11-01T10:00-05:00[US/Eastern]
2015-11-01T10:00-05:00[US/Eastern]
Duration.ofDays(1) is 24h
Period.ofDays(1) is 1 day
For me, they are the same? what I'm missing here? thanks
-
- Site Admin
- Posts: 10113
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1484 :
Period of 24h and Duration of 1D are not same. Check this article by Oracle: https://docs.oracle.com/javase/tutorial ... eriod.html
It explains the difference between Duration and Period.
It explains the difference between Duration and Period.
If you like our products and services, please help us by posting your review here.
-
- Posts: 8
- Joined: Tue Jan 26, 2021 7:55 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1484 :
Hi, I understand what the Period add 24h and Duration 1 Day. But why the hour is changed from 10:00 to 9:00?
2015-11-01T09:00-05:00[US/Eastern]
Year DST Start (Clock Forward) DST End (Clock Backward)
2015 Sunday, 29 March, 02:00 Sunday, 25 October, 03:00
Thanks.
2015-11-01T09:00-05:00[US/Eastern]
Year DST Start (Clock Forward) DST End (Clock Backward)
2015 Sunday, 29 March, 02:00 Sunday, 25 October, 03:00
Thanks.
-
- Site Admin
- Posts: 10113
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1484 :
Because the problem statement says, "Given that Daylight Savings Time ends on Nov 1 at 2 AM".
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: Bing [Bot] and 25 guests