시작하기무료로 시작하기

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.

이 연습은 강의의 일부입니다

Cleaning Data in Java

강의 보기

연습 안내

  • 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.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

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);
    }
}
코드 편집 및 실행