タイムゾーンの変換
あなたは電子機器の在庫について、複数のタイムゾーンにまたがる製造日を管理しています。製造日を2つのタイムゾーン間で変換しましょう。
LocalDate、ZoneId、ZonedDateTime などの必要なパッケージはあらかじめインポートされています。
この演習はコースの一部です
Java によるデータクリーニング
演習の手順
dateをニューヨークのタイムゾーンにおける日付の開始時刻に変換しましょう。- ニューヨーク時間の
nyTimeをロサンゼルス時間の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);
}
}