⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e370. getting the current time in another time zone.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
// Get the current time in Hong Kong
    Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("Hongkong"));
    
    int hour12 = cal.get(Calendar.HOUR);         // 0..11
    int minutes = cal.get(Calendar.MINUTE);      // 0..59
    int seconds = cal.get(Calendar.SECOND);      // 0..59
    boolean am = cal.get(Calendar.AM_PM) == Calendar.AM;
    
    // Get the current hour-of-day at GMT
    cal.setTimeZone(TimeZone.getTimeZone("GMT"));
    int hour24 = cal.get(Calendar.HOUR_OF_DAY);  // 0..23
    
    // Get the current local hour-of-day
    cal.setTimeZone(TimeZone.getDefault());
    hour24 = cal.get(Calendar.HOUR_OF_DAY);      // 0..23

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -