To display the available time zones in Linux, you can use the timedatectl command or the getAvailableZoneIds() method in Java. Here’s how to do it using both methods:
Using timedatectl Command
Open your terminal and run the following command:
timedatectl list-timezones
This will display a list of all available time zones.
Using Java
If you want to display time zones using Java, you can use the following code snippet:
import java.time.ZoneId;
public class TimeZoneDisplay {
public static void main(String[] args) {
System.out.println("Available time-zones:");
ZoneId.getAvailableZoneIds().forEach(System.out::println);
}
}
This Java program will print all available time zones to the console.
You can choose either method based on your preference or the context in which you are working.
