Java Date Time Java Java API
java.time.Year
public static Year now()
Obtains the current year from the system clock in the default time-zone.
public static Year now(ZoneId zone)
Obtains the current year from the system clock in the specified time-zone.
public static Year now(Clock clock)
Obtains the current year from the specified clock.
package com.logicbig.example.year;import java.time.Year;public class NowExample { public static void main(String... args) { Year y = Year.now(); System.out.println(y); }}
2017
package com.logicbig.example.year;import java.time.Year;import java.time.ZoneId;public class NowExample2 { public static void main(String... args) { Year y = Year.now(ZoneId.of("US/Hawaii")); System.out.println(y); }}
package com.logicbig.example.year;import java.time.Clock;import java.time.Year;import java.time.ZoneId;public class NowExample3 { public static void main(String... args) { Clock c = Clock.tickMinutes(ZoneId.of("Asia/Manila")); Year y = Year.now(c); System.out.println(y); }}