gpt4 book ai didi

java - java.util.Date 语言环境中的 toString() 方法是否独立?

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:28:50 25 4
gpt4 key购买 nike

    try {
SimpleDateFormat strTemp = new SimpleDateFormat("ddMMMyy", Locale.US);
Date reasult = strTemp.parse(input);
String checkDate = reasult.toString().substring(8, 10) + reasult.toString().substring(4, 7) + reasult.toString().substring(26);
if (!checkDate.toUpperCase().equals(input))
return false;

else
return true;
} catch (Exception ex) {
return false;
}

API 告诉我 java.util.Date.toString() 就像格式“dow mon dd hh:mm:ss zzz yyyy”,我只想知道 toString() 的内容格式是否会改变Windows 语言环境改变了吗?比如“俄语”,“英语”,提示输入相同,checkDate值相同?感谢您的帮助。

最佳答案

Date.toString() 与语言环境无关。您可以观察到的最显着的变化是时区,这取决于您计算机的时区设置。这是 by design .

Converts this Date object to a String of the form:

   dow mon dd hh:mm:ss zzz yyyy

where:

  • dow is the day of the week (Sun, Mon, Tue, Wed, Thu, Fri, Sat).
  • mon is the month (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec).
  • dd is the day of the month (01 through 31), as two decimal digits.
  • hh is the hour of the day (00 through 23), as two decimal digits.
  • mm is the minute within the hour (00 through 59), as two decimal digits.
  • ss is the second within the minute (00 through 61, as two decimal digits.
  • zzz is the time zone (and may reflect daylight saving time). Standard time zone abbreviations include those recognized by the method parse. If time zone information is not available, then zzz is empty - that is, it consists of no characters at all.
  • yyyy is the year, as four decimal digits.

关于java - java.util.Date 语言环境中的 toString() 方法是否独立?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16210409/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com