Creates and returns the current month-day from the system clock in the default time-zone.
Creates and returns the current month-day from the system clock in the the provided time-zone.
Creates and returns the month-day from the specified clock.
package com.logicbig.example.monthday;
import java.time.MonthDay;
import java.time.ZoneId;
public class NowExample2 {
public static void main(String... args) {
ZoneId z = ZoneId.of("Japan");
System.out.println(z);
MonthDay m = MonthDay.now(z);
System.out.println(m);
ZoneId z2 = ZoneId.of("Canada/Central");
System.out.println(z2);
MonthDay m2 = MonthDay.now(z2);
System.out.println(m2);
}
}
Output
Japan
--05-02
Canada/Central
--05-01
package com.logicbig.example.monthday;
import java.time.Clock;
import java.time.Duration;
import java.time.MonthDay;
public class NowExample3 {
public static void main(String... args) {
Clock c = Clock.tick(Clock.systemDefaultZone(), Duration.ofDays(5));
System.out.println(c);
MonthDay m = MonthDay.now(c);
System.out.println(m);
}
}
Output
TickClock[SystemClock[America/Chicago],PT120H]
--04-28