4. Dates, Times, Locales and Resource bundles Flashcards
How are the classes in java.time organised?
- Local dates and times: these dates are local to your time zone, the classes: LocalDate, LocalTime, LocalDateTime
- Zoned dates and times: these dates include time-zone information, the classes:
ZonedDateTime and OffsetDateTime - Formatters for dates and times: you can parse dates with patterns and in a variety of styles,
the classes: format.DateTimeFormatter - Adjustments to dates and times: you can adjust and manipulate dates and times by handy
increments, the classes: temporal.TemporalAdjusters and temporal.ChronoUnit - Periods, Durations: represent an amount of time, periods for days or longer and durations
for shorter periods (minutes seconds), classes: Periods and Durations - Instants: represent a specific instant in time, so you can compute the number of minutes
between two instants, the class: Instants
What does the LocalDate.parse(String string) do?
to parse a string that matches the date (so string need to be in the order of ISO-
8601)
What does the LocalDate.of(YYYY-MM-DD) do?
to parse a string that matches the date (so string need to be in the order of ISO-
8601)
What are ZoneRules for?
With ZoneRules the class captures the current rules about daylight savings in various parts of the world. It gives answer on the question is the current ZoneId in daylight savings time?
What are ZoneRules for?
With ZoneRules the class captures the current rules about daylight savings in various parts of the world. It gives answer on the question is the current ZoneId in daylight savings time?
Which Adjustments are there?
You can add days and hours with handy methods of LocalDate and ZonedDateTime classes, suchs as
plusMinutes(). plusYears(), minusWeeks(), minusSeconds().
What are temporalAdjusters?
The class temporalAdjusters has a whole slew of handy methods to make a TemporalAdjuster for a variety of scenarios, such as firstDayOfNextYear(), lastDayOfMonth()
What is a Period?
The Period Class in Java class obtains a quantity or amount of time in terms of years, months and days.
What is the output of Period?
Output of Periods is P for instance P1D, P1Y
What will the minus() method do?
You can call the minus() method on ZonedDateTime and DateTime classes with an argument of a
Period to minus that period on the current DateTime.
What is a Duration?
A Duration object ( java. time. Duration ) represents a period of time between two Instant objects.
What is the output of a Duration?
If you print out the Duration object you will get something like this: PT1H18M. PT means period of
time, 1H18M, means 1 hour 18 minutes.
What is an Instance?
An instant represent an instant in time. (seconds and nano seconds)
How to create a LocalDate?
LocalDate.now();
LocalDate.of(2017, 8, 21);
LocalDate.parse(“2017-08-21”);
How to create a LocalTime?
LocalTime.now();
LocalTime.of(10, 19, 36);
LocalTime.parse(“10:19:36”);