mirror of
https://gitee.com/dromara/hutool.git
synced 2026-02-09 09:16:26 +08:00
fix timezone
This commit is contained in:
@@ -21,6 +21,7 @@ import cn.hutool.v7.core.date.format.FastDateFormat;
|
||||
import cn.hutool.v7.core.date.format.FastDatePrinter;
|
||||
import cn.hutool.v7.core.date.format.SimpleDateBasic;
|
||||
import cn.hutool.v7.core.text.StrUtil;
|
||||
import cn.hutool.v7.core.util.JdkUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
@@ -669,7 +670,13 @@ public class FastDateParser extends SimpleDateBasic implements PositionDateParse
|
||||
for (final String[] zoneNames : zones) {
|
||||
// offset 0 is the time zone ID and is not localized
|
||||
final String tzId = zoneNames[ID];
|
||||
if ("GMT".equalsIgnoreCase(tzId)) {
|
||||
if(JdkUtil.IS_AT_LEAST_JDK25){
|
||||
// issue#4100 JDK25+所有三位简写失效
|
||||
// 见:https://stackoverflow.com/questions/41672825/which-three-letter-time-zone-ids-are-not-deprecated
|
||||
if(tzId.length() == 3){
|
||||
continue;
|
||||
}
|
||||
}else if ("GMT".equalsIgnoreCase(tzId)) {
|
||||
continue;
|
||||
}
|
||||
final TimeZone tz = TimeZone.getTimeZone(tzId);
|
||||
|
||||
@@ -30,9 +30,9 @@ public class JdkUtil {
|
||||
*/
|
||||
public static final int JVM_VERSION;
|
||||
/**
|
||||
* 是否大于等于JDK17
|
||||
* 是否大于等于JDK25
|
||||
*/
|
||||
public static final boolean IS_AT_LEAST_JDK17;
|
||||
public static final boolean IS_AT_LEAST_JDK25;
|
||||
|
||||
/**
|
||||
* 是否Android环境
|
||||
@@ -51,7 +51,7 @@ public class JdkUtil {
|
||||
static {
|
||||
// JVM版本
|
||||
JVM_VERSION = _getJvmVersion();
|
||||
IS_AT_LEAST_JDK17 = JVM_VERSION >= 17;
|
||||
IS_AT_LEAST_JDK25 = JVM_VERSION >= 25;
|
||||
|
||||
// JVM名称
|
||||
final String jvmName = _getJvmName();
|
||||
@@ -73,12 +73,12 @@ public class JdkUtil {
|
||||
|
||||
/**
|
||||
* 根据{@code java.specification.version}属性值,获取版本号<br>
|
||||
* 默认8
|
||||
* 默认17
|
||||
*
|
||||
* @return 版本号
|
||||
*/
|
||||
private static int _getJvmVersion() {
|
||||
int jvmVersion = 8;
|
||||
int jvmVersion = 17;
|
||||
|
||||
String javaSpecVer = SystemUtil.getQuietly("java.specification.version");
|
||||
if (StrUtil.isNotBlank(javaSpecVer)) {
|
||||
|
||||
@@ -16,21 +16,15 @@
|
||||
|
||||
package cn.hutool.v7.core.util;
|
||||
|
||||
import cn.hutool.v7.core.lang.Console;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class JdkUtilTest {
|
||||
@Test
|
||||
public void jvmVersionTest() {
|
||||
final int jvmVersion = JdkUtil.JVM_VERSION;
|
||||
Assertions.assertTrue(jvmVersion >= 8);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void getJvmNameTest() {
|
||||
Console.log(JdkUtil.IS_AT_LEAST_JDK17);
|
||||
assertTrue(jvmVersion >= 17);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user