BaşlayınÜcretsiz başlayın

Converting time zones

You are tracking the manufacturing dates of your electronics inventory across time zones. Convert the manufacturing dates between two time zones!

The necessary packages such as LocalDate, ZoneId and ZonedDateTime have been imported for you.

Bu egzersiz, kursun bir parçasıdır

Cleaning Data in Java

Kursa Göz Atın

Egzersiz talimatları

  • Convert the date to the New York time zone at the start of day.
  • Convert the New York time nyTime to Los Angeles time laTime.

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

public class DateStandardizationExample {
    public static void main(String[] args) {
        LocalDate date = LocalDate.parse("2023-01-01");
        
        // Convert the date to the New York time zone at the start of day
        ZonedDateTime nyTime = ____.____(ZoneId.of("America/New_York"));
        // Convert the New York time to Los Angeles time
        ZonedDateTime laTime = ____.____(ZoneId.of("America/Los_Angeles"));
        
        System.out.println("New York time: " + nyTime);
		System.out.println("Los Angeles time: " + laTime);
    }
}
Kodu Düzenle ve Çalıştır