We would like to know how to get current (local) time in Los Angeles.
import java.time.LocalTime; import java.time.ZoneId; /*from www .j a v a 2 s .co m*/ public class Main { public static void main(String[] args) { LocalTime currentTimeInLosAngeles = LocalTime.now(ZoneId.of("America/Los_Angeles")); System.out.println(currentTimeInLosAngeles); // 23:08:18.104 } }
The code above generates the following result.