📄 timeutil.java
字号:
"Africa/Tunis", "Africa/Ceuta" }); tempMap.put("MHT", new String[] { "Pacific/Majuro", "Pacific/Kwajalein" }); tempMap.put("MMT", new String[] { "Indian/Maldives", "Europe/Minsk", "Europe/Moscow", "Asia/Rangoon", "Asia/Ujung_Pandang", "Asia/Colombo", "Pacific/Easter", "Africa/Monrovia", "America/Managua", "America/Montevideo" }); tempMap.put("MOST", new String[] { "Asia/Macao" }); tempMap.put("MOT", new String[] { "Asia/Macao" }); tempMap.put("MPT", new String[] { "Pacific/Saipan" }); tempMap.put("MSK", new String[] { "Europe/Minsk", "Europe/Tallinn", "Europe/Riga", "Europe/Vilnius", "Europe/Chisinau", "Europe/Kiev", "Europe/Uzhgorod", "Europe/Zaporozhye", "Europe/Simferopol" }); tempMap.put("MST", new String[] { "Europe/Moscow", "America/Denver", "America/Phoenix", "America/Boise", "America/Regina", "America/Swift_Current", "America/Edmonton", "America/Dawson_Creek", "America/Cambridge_Bay", "America/Yellowknife", "America/Inuvik", "America/Mexico_City", "America/Chihuahua", "America/Hermosillo", "America/Mazatlan", "America/Tijuana" }); tempMap.put("MUT", new String[] { "Indian/Mauritius" }); tempMap.put("MVT", new String[] { "Indian/Maldives" }); tempMap.put("MWT", new String[] { "America/Denver", "America/Phoenix", "America/Boise" }); tempMap .put("MYT", new String[] { "Asia/Kuala_Lumpur", "Asia/Kuching" }); tempMap.put("NCST", new String[] { "Pacific/Noumea" }); tempMap.put("NCT", new String[] { "Pacific/Noumea" }); tempMap.put("NDT", new String[] { "America/Nome", "America/Adak", "America/St_Johns", "America/Goose_Bay" }); tempMap.put("NEGT", new String[] { "America/Paramaribo" }); tempMap.put("NFT", new String[] { "Europe/Paris", "Europe/Oslo", "Pacific/Norfolk" }); tempMap.put("NMT", new String[] { "Pacific/Norfolk" }); tempMap.put("NOVMT", new String[] { "Asia/Novosibirsk" }); tempMap.put("NOVST", new String[] { "Asia/Novosibirsk" }); tempMap.put("NOVT", new String[] { "Asia/Novosibirsk" }); tempMap.put("NPT", new String[] { "Asia/Katmandu" }); tempMap.put("NRT", new String[] { "Pacific/Nauru" }); tempMap.put("NST", new String[] { "Europe/Amsterdam", "Pacific/Pago_Pago", "Pacific/Midway", "America/Nome", "America/Adak", "America/St_Johns", "America/Goose_Bay" }); tempMap.put("NUT", new String[] { "Pacific/Niue" }); tempMap.put("NWT", new String[] { "America/Nome", "America/Adak" }); tempMap.put("NZDT", new String[] { "Antarctica/McMurdo" }); tempMap.put("NZHDT", new String[] { "Pacific/Auckland" }); tempMap.put("NZST", new String[] { "Antarctica/McMurdo", "Pacific/Auckland" }); tempMap.put("OMSMT", new String[] { "Asia/Omsk" }); tempMap.put("OMSST", new String[] { "Asia/Omsk" }); tempMap.put("OMST", new String[] { "Asia/Omsk" }); tempMap.put("PDDT", new String[] { "America/Inuvik", "America/Whitehorse", "America/Dawson" }); tempMap.put("PDT", new String[] { "America/Los_Angeles", "America/Juneau", "America/Boise", "America/Vancouver", "America/Dawson_Creek", "America/Inuvik", "America/Whitehorse", "America/Dawson", "America/Tijuana" }); tempMap.put("PEST", new String[] { "America/Lima" }); tempMap.put("PET", new String[] { "America/Lima" }); tempMap.put("PETMT", new String[] { "Asia/Kamchatka" }); tempMap.put("PETST", new String[] { "Asia/Kamchatka" }); tempMap.put("PETT", new String[] { "Asia/Kamchatka" }); tempMap.put("PGT", new String[] { "Pacific/Port_Moresby" }); tempMap.put("PHOT", new String[] { "Pacific/Enderbury" }); tempMap.put("PHST", new String[] { "Asia/Manila" }); tempMap.put("PHT", new String[] { "Asia/Manila" }); tempMap.put("PKT", new String[] { "Asia/Karachi" }); tempMap.put("PMDT", new String[] { "America/Miquelon" }); tempMap.put("PMMT", new String[] { "Pacific/Port_Moresby" }); tempMap.put("PMST", new String[] { "America/Miquelon" }); tempMap.put("PMT", new String[] { "Antarctica/DumontDUrville", "Europe/Prague", "Europe/Paris", "Europe/Monaco", "Africa/Algiers", "Africa/Tunis", "America/Panama", "America/Paramaribo" }); tempMap.put("PNT", new String[] { "Pacific/Pitcairn" }); tempMap.put("PONT", new String[] { "Pacific/Ponape" }); tempMap.put("PPMT", new String[] { "America/Port-au-Prince" }); tempMap.put("PST", new String[] { "Pacific/Pitcairn", "America/Los_Angeles", "America/Juneau", "America/Boise", "America/Vancouver", "America/Dawson_Creek", "America/Inuvik", "America/Whitehorse", "America/Dawson", "America/Hermosillo", "America/Mazatlan", "America/Tijuana" }); tempMap.put("PWT", new String[] { "Pacific/Palau", "America/Los_Angeles", "America/Juneau", "America/Boise", "America/Tijuana" }); tempMap.put("PYST", new String[] { "America/Asuncion" }); tempMap.put("PYT", new String[] { "America/Asuncion" }); tempMap.put("QMT", new String[] { "America/Guayaquil" }); tempMap.put("RET", new String[] { "Indian/Reunion" }); tempMap.put("RMT", new String[] { "Atlantic/Reykjavik", "Europe/Rome", "Europe/Riga", "Asia/Rangoon" }); tempMap.put("S", new String[] { "Europe/Moscow" }); tempMap.put("SAMMT", new String[] { "Europe/Samara" }); tempMap .put("SAMST", new String[] { "Europe/Samara", "Asia/Samarkand" }); tempMap.put("SAMT", new String[] { "Europe/Samara", "Asia/Samarkand", "Pacific/Pago_Pago", "Pacific/Apia" }); tempMap.put("SAST", new String[] { "Africa/Maseru", "Africa/Windhoek", "Africa/Johannesburg", "Africa/Mbabane" }); tempMap.put("SBT", new String[] { "Pacific/Guadalcanal" }); tempMap.put("SCT", new String[] { "Indian/Mahe" }); tempMap.put("SDMT", new String[] { "America/Santo_Domingo" }); tempMap.put("SGT", new String[] { "Asia/Singapore" }); tempMap.put("SHEST", new String[] { "Asia/Aqtau" }); tempMap.put("SHET", new String[] { "Asia/Aqtau" }); tempMap.put("SJMT", new String[] { "America/Costa_Rica" }); tempMap.put("SLST", new String[] { "Africa/Freetown" }); tempMap.put("SMT", new String[] { "Atlantic/Stanley", "Europe/Stockholm", "Europe/Simferopol", "Asia/Phnom_Penh", "Asia/Vientiane", "Asia/Kuala_Lumpur", "Asia/Singapore", "Asia/Saigon", "America/Santiago" }); tempMap.put("SRT", new String[] { "America/Paramaribo" }); tempMap.put("SST", new String[] { "Pacific/Pago_Pago", "Pacific/Midway" }); tempMap.put("SVEMT", new String[] { "Asia/Yekaterinburg" }); tempMap.put("SVEST", new String[] { "Asia/Yekaterinburg" }); tempMap.put("SVET", new String[] { "Asia/Yekaterinburg" }); tempMap.put("SWAT", new String[] { "Africa/Windhoek" }); tempMap.put("SYOT", new String[] { "Antarctica/Syowa" }); tempMap.put("TAHT", new String[] { "Pacific/Tahiti" }); tempMap .put("TASST", new String[] { "Asia/Samarkand", "Asia/Tashkent" }); tempMap.put("TAST", new String[] { "Asia/Samarkand", "Asia/Tashkent" }); tempMap.put("TBIST", new String[] { "Asia/Tbilisi" }); tempMap.put("TBIT", new String[] { "Asia/Tbilisi" }); tempMap.put("TBMT", new String[] { "Asia/Tbilisi" }); tempMap.put("TFT", new String[] { "Indian/Kerguelen" }); tempMap.put("TJT", new String[] { "Asia/Dushanbe" }); tempMap.put("TKT", new String[] { "Pacific/Fakaofo" }); tempMap.put("TMST", new String[] { "Asia/Ashkhabad" }); tempMap.put("TMT", new String[] { "Europe/Tallinn", "Asia/Tehran", "Asia/Ashkhabad" }); tempMap.put("TOST", new String[] { "Pacific/Tongatapu" }); tempMap.put("TOT", new String[] { "Pacific/Tongatapu" }); tempMap.put("TPT", new String[] { "Asia/Dili" }); tempMap.put("TRST", new String[] { "Europe/Istanbul" }); tempMap.put("TRT", new String[] { "Europe/Istanbul" }); tempMap.put("TRUT", new String[] { "Pacific/Truk" }); tempMap.put("TVT", new String[] { "Pacific/Funafuti" }); tempMap.put("ULAST", new String[] { "Asia/Ulaanbaatar" }); tempMap.put("ULAT", new String[] { "Asia/Ulaanbaatar" }); tempMap.put("URUT", new String[] { "Asia/Urumqi" }); tempMap.put("UYHST", new String[] { "America/Montevideo" }); tempMap.put("UYT", new String[] { "America/Montevideo" }); tempMap.put("UZST", new String[] { "Asia/Samarkand", "Asia/Tashkent" }); tempMap.put("UZT", new String[] { "Asia/Samarkand", "Asia/Tashkent" }); tempMap.put("VET", new String[] { "America/Caracas" }); tempMap.put("VLAMT", new String[] { "Asia/Vladivostok" }); tempMap.put("VLAST", new String[] { "Asia/Vladivostok" }); tempMap.put("VLAT", new String[] { "Asia/Vladivostok" }); tempMap.put("VUST", new String[] { "Pacific/Efate" }); tempMap.put("VUT", new String[] { "Pacific/Efate" }); tempMap.put("WAKT", new String[] { "Pacific/Wake" }); tempMap.put("WARST", new String[] { "America/Jujuy", "America/Mendoza" }); tempMap .put("WART", new String[] { "America/Jujuy", "America/Mendoza" }); tempMap.put("WAST", new String[] { "Africa/Ndjamena", "Africa/Windhoek" }); tempMap.put("WAT", new String[] { "Africa/Luanda", "Africa/Porto-Novo", "Africa/Douala", "Africa/Bangui", "Africa/Ndjamena", "Africa/Kinshasa", "Africa/Brazzaville", "Africa/Malabo", "Africa/Libreville", "Africa/Banjul", "Africa/Conakry", "Africa/Bissau", "Africa/Bamako", "Africa/Nouakchott", "Africa/El_Aaiun", "Africa/Windhoek", "Africa/Niamey", "Africa/Lagos", "Africa/Dakar", "Africa/Freetown" }); tempMap.put("WEST", new String[] { "Atlantic/Faeroe", "Atlantic/Azores", "Atlantic/Madeira", "Atlantic/Canary", "Europe/Brussels", "Europe/Luxembourg", "Europe/Monaco", "Europe/Lisbon", "Europe/Madrid", "Africa/Algiers", "Africa/Casablanca", "Africa/Ceuta" }); tempMap.put("WET", new String[] { "Atlantic/Faeroe", "Atlantic/Azores", "Atlantic/Madeira", "Atlantic/Canary", "Europe/Andorra", "Europe/Brussels", "Europe/Luxembourg", "Europe/Monaco", "Europe/Lisbon", "Europe/Madrid", "Africa/Algiers", "Africa/Casablanca", "Africa/El_Aaiun", "Africa/Ceuta" }); tempMap.put("WFT", new String[] { "Pacific/Wallis" }); tempMap.put("WGST", new String[] { "America/Godthab" }); tempMap.put("WGT", new String[] { "America/Godthab" }); tempMap.put("WMT", new String[] { "Europe/Vilnius", "Europe/Warsaw" }); tempMap.put("WST", new String[] { "Antarctica/Casey", "Pacific/Apia", "Australia/Perth" }); tempMap.put("YAKMT", new String[] { "Asia/Yakutsk" }); tempMap.put("YAKST", new String[] { "Asia/Yakutsk" }); tempMap.put("YAKT", new String[] { "Asia/Yakutsk" }); tempMap.put("YAPT", new String[] { "Pacific/Yap" }); tempMap.put("YDDT", new String[] { "America/Whitehorse", "America/Dawson" }); tempMap.put("YDT", new String[] { "America/Yakutat", "America/Whitehorse", "America/Dawson" }); tempMap.put("YEKMT", new String[] { "Asia/Yekaterinburg" }); tempMap.put("YEKST", new String[] { "Asia/Yekaterinburg" }); tempMap.put("YEKT", new String[] { "Asia/Yekaterinburg" }); tempMap.put("YERST", new String[] { "Asia/Yerevan" }); tempMap.put("YERT", new String[] { "Asia/Yerevan" }); tempMap.put("YST", new String[] { "America/Yakutat", "America/Whitehorse", "America/Dawson" }); tempMap.put("YWT", new String[] { "America/Yakutat" }); ABBREVIATED_TIMEZONES = Collections.unmodifiableMap(tempMap); } /** * Change the given times from one timezone to another * * @param conn * the current connection to the MySQL server * @param t * the times to change * @param fromTz * the timezone to change from * @param toTz * the timezone to change to * * @return the times changed to the timezone 'toTz' */ public static Time changeTimezone(Connection conn, Calendar sessionCalendar, Calendar targetCalendar, Time t, TimeZone fromTz, TimeZone toTz, boolean rollForward) { if ((conn != null)) { if (conn.getUseTimezone() && !conn.getNoTimezoneConversionForTimeType()) { // Convert the timestamp from GMT to the server's timezone Calendar fromCal = Calendar.getInstance(fromTz); fromCal.setTime(t); int fromOffset = fromCal.get(Calendar.ZONE_OFFSET) + fromCal.get(Calendar.DST_OFFSET); Calendar toCal = Calendar.getInstance(toTz); toCal.setTime(t); int toOffset = toCal.get(Calendar.ZONE_OFFSET) + toCal.get(Calendar.DST_OFFSET); int offsetDiff = fromOffset - toOffset; long toTime = toCal.getTime().getTime(); if (rollForward || (conn.isServerTzUTC() && !conn.isClientTzUTC())) { toTime += offsetDiff; } else { toTime -= offsetDiff; } Time changedTime = new Time(toTime); return changedTime; } else if (conn.getUseJDBCCompliantTimezoneShift()) { if (targetCalendar != null) { Time adjustedTime = new Time( jdbcCompliantZoneShift(sessionCalendar, targetCalendar, t)); return adjustedTime; } } } return t; } /** * Change the given timestamp from one timezone to another * * @param conn * the current connection to the MySQL server * @param tstamp * the timestamp to change * @param fromTz * the timezone to change from * @param toTz * the timezone to change to * * @return the timestamp changed to the timezone 'toTz' */ public static Timestamp changeTimezone(Connection conn, Calendar sessionCalendar, Calendar targetCalendar, Timestamp tstamp, TimeZone fromTz, TimeZone toTz, boolean rollForward) { if ((conn != null)) { if (conn.getUseTimezone()) { // Convert the timestamp from GMT to the server's timezone Calendar fromCal = Calendar.getInstance(fromTz); fromCal.setTime(tstamp);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -