Chapter 5: Dates Strings, and Localization Flashcards

1
Q

What is the GMT of 2015-06-20T07:50+02:00[Europe/Paris]?

A

GMT 2015-06-20 5:50

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to get an instance of LocalDate?

A

LocalDate ld = LocalDate.of(year, month, day)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to get an instance of LocalTime?

A

LocalTime lt = LocalTime.of(hour, minute,second)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to get an instance of LocalDateTime?

A

LocalDateTime ldt = LocalDateTime.of(year, month, day, hour, minute, second)

or

LocalDateTime ldt = LocalDateTime.of(localdate, localtime)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to get an instance of ZonedDateTime

A

ZonedDateTime.of(int year, int month,
int dayOfMonth, int hour, int minute, int second, int nanos, ZoneId zone)
or
ZonedDateTime.of(LocalDate date, LocalTime time, ZoneId zone)

or

ZonedDateTime.of(LocalDateTime dateTime, ZoneId zone)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Enumarate the ways to set a instantiate a period

A

Period.ofDays(), Period.ofWeeks(), Period.ofMonths(), Period.ofYears(), Period.of(year, month, day)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Printing Period objects, what is the output of Period.ofMonths(3)

A

P3M

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Enumerate the ways to get an instance of Duration

A

Duration.ofDays(), Duration.ofHours(), Duration.ofMinutes, Duration.ofSeconds, Duration.ofMillis(), Duration.ofNanos()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to add period to a LocalDate object ld?

A

ld.plus(Period p).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

A class that represents a specific moment in time in the GMT timezone.

A

Instant now = Instant.now()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Generate a Locale for German and Germany

A
Locale l = Locale.GERMANY;
Locale l = new Locale("de");
Locale l = new Locale("de", "DE");
Locale l = new Locale.Builder().setLanguage("de").setRegion("DE").build();
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Instantiate a ResourceBundle

A

ResourceBundle rb = ResourceBundle.getBundle(“resourcename”, locale)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

ResourceBundle.getBundle(“Zoo”, Locale.French”), How many resources will be searched?

A
Zoo_fr.java
Zoo_fr.properties
Zoo_en.java
Zoo_en.properties
Zoo.java
Zoo.properties
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How get an instance of NumberFormat?

A

NumberFormat.getInstance();
NumberFormat.getInstance(Locale.US);
NumberFormat.getCurrencyInstance();
NumberFormat.getPercentInstance();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Number format method to convert a number to String

A

NumberFormat.format()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

NumberFormat method to convert String to Number

A

NumberFormat.parse();

17
Q

What is the output of
NumberFormat fr = NumberFormat.getInstance(Locale.FRANCE);
String s = “40.45”;
System.out.println(fr.parse(s));

A

40

18
Q

Exception thrown by NumberFormat when the text is unparseable?

A

ParseException

19
Q

What is the return type of parse?

A

Number object

20
Q

How to format LocalDate object?

A

LocalDate ld = LocalDate.now();

ld.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);

21
Q

Enumerate the ofLocalized methods of DateFormatter

A

DateFormatter.ofLocalizedTime(FormatStyle.SHORT);
DateFormatter.ofLocalizedDate(FormatStyle.SHORT)
DateFormatter.ofLocalizedDateTime(FormatStyle.SHORT)