Formatting Flashcards

1
Q

How do we format date or time?

A

Using DateTimeFormatter

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

How can we set format of date or time using DateTimeFormatter?

A

DateTimeFormatter.ofPattern() or predefined DateTimeFormatter.ISO_LOCAL_TIME, DateTimeFormatter.ISO_LOCAL_DATE, DateTimeFormatter.ISO_LOCAL_DATE_TIME

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

What is potential pitfall when using predefined “ISO” values?

A

Mix of date instead of time, and vice versa

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

How do we use DateTimeFormatter on LocalDateTime

A

dateTime.format(DateTimeFormatter.ofPattern(“”))

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

What letters are used in date time patterns?

A

m, M, h, s, d, M, a

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

How do we format decimal numbers?

A

Using DecimalFormat

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

What is the difference between 0 and # in DecimalFormat pattern?

A

Values at # are omitted if missing, 0 are not - it shows 0

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

How do we format number using DecimalFormat ?

A

new DecimalFormat(“###.##”).format(number)

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

What class does DecimalFormat extend?

A

NumberFormat

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