Given a time of 10am in Japan, get the local time
import java.util.Calendar; import java.util.GregorianCalendar; import java.util.TimeZone; public class Main { public static void main(String[] argv) throws Exception { Calendar japanCal = new GregorianCalendar(TimeZone.getTimeZone("Japan")); japanCal.set(Calendar.HOUR_OF_DAY, 10); // 0..23 japanCal.set(Calendar.MINUTE, 0); japanCal.set(Calendar.SECOND, 0); } }
1. | Locales for Calendar | ||
2. | Calendar Manipulation for I18N (Internationalization) | ||
3. | Create an instance using Japan's time zone and set it with the local UTC | ||
4. | Get the foreign time |