-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonthDayExamples.java
More file actions
43 lines (38 loc) · 1.2 KB
/
MonthDayExamples.java
File metadata and controls
43 lines (38 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.time.LocalDate;
import java.time.MonthDay;
import java.time.temporal.ChronoField;
import java.time.temporal.ValueRange;
public class MonthDayExamples {
public static void main(String[] args) {
System.out.println("Month Day Example");
monthDayExample();
System.out.println("Month Day Is Valid Year Example");
monthDayIsValidYearExample();
System.out.println("Month Day Get Example");
monthDayGetExample();
System.out.println("Month Day Range Example");
monthDayRangeExample();
}
public static void monthDayExample() {
MonthDay monthDay = MonthDay.now();
LocalDate date = monthDay.atYear(1994);
System.out.println(date);
}
public static void monthDayIsValidYearExample() {
MonthDay month = MonthDay.now();
boolean b = month.isValidYear(2012);
System.out.println(b);
}
public static void monthDayGetExample() {
MonthDay month = MonthDay.now();
long n = month.get(ChronoField.MONTH_OF_YEAR);
System.out.println(n);
}
public static void monthDayRangeExample() {
MonthDay month = MonthDay.now();
ValueRange r1 = month.range(ChronoField.MONTH_OF_YEAR);
System.out.println(r1);
ValueRange r2 = month.range(ChronoField.DAY_OF_MONTH);
System.out.println(r2);
}
}