Javascript setTimeout(Javascript setTimeout)
你能告诉我为什么这个工程:
PageMethods.UpdateForcedDisposition(forcedDisposition, a.value, SucceededCallback, FailedCallback);
当这不?
setTimeout("PageMethods.UpdateForcedDisposition(" + forcedDisposition + "," + a.value + ", SucceededCallback, FailedCallback);", 1000);
有趣的是,类似的调用与
setTimeout
:setTimeout("PageMethods.UpdateSales(" + id + ", " + a.value + ", SucceededCallback, FailedCallback);", 1000);
......我很难过!
Can you tell me why this works:
PageMethods.UpdateForcedDisposition(forcedDisposition, a.value, SucceededCallback, FailedCallback);
When this doesn’t?
setTimeout("PageMethods.UpdateForcedDisposition(" + forcedDisposition + "," + a.value + ", SucceededCallback, FailedCallback);", 1000);
Interestingly, a similar call works with
setTimeout
:setTimeout("PageMethods.UpdateSales(" + id + ", " + a.value + ", SucceededCallback, FailedCallback);", 1000);
…I’m stumped!
原文:https://stackoverflow.com/questions/4128938
更新时间:2023-08-26 10:08
最满意答案
你的模式根本不对应于输入字符串......它不起作用也就不足为奇了。 这可能会更好:
SimpleDateFormat sdf = new SimpleDateFormat("EE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH);
然后用你需要的格式打印你需要第二个SimpleDateFormat:
Date parsedDate = sdf.parse(date); SimpleDateFormat print = new SimpleDateFormat("MMM d, yyyy HH:mm:ss"); System.out.println(print.format(parsedDate));
笔记:
- 您应该包含语言环境,就好像您的语言环境不是英语一样,日期名称可能无法识别
- IST不明确,可能会导致问题,因此如果可能,应在输入中使用适当的时区名称。
Your pattern does not correspond to the input string at all... It is not surprising that it does not work. This would probably work better:
SimpleDateFormat sdf = new SimpleDateFormat("EE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH);
Then to print with your required format you need a second SimpleDateFormat:
Date parsedDate = sdf.parse(date); SimpleDateFormat print = new SimpleDateFormat("MMM d, yyyy HH:mm:ss"); System.out.println(print.format(parsedDate));
Notes:
- you should include the locale as if your locale is not English, the day name might not be recognised
- IST is ambiguous and can lead to problems so you should use the proper time zone name if possible in your input.
相关问答
更多-
你的模式根本不对应于输入字符串......它不起作用也就不足为奇了。 这可能会更好: SimpleDateFormat sdf = new SimpleDateFormat("EE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH); 然后用你需要的格式打印你需要第二个SimpleDateFormat: Date parsedDate = sdf.parse(date); SimpleDa ...
-
错误的解析模式 您的解析模式最后包含Z 该符号表示您期望从UTC偏移。 但是您的输入字符串缺少任何偏移或时区信息。 所以你的数据与你告诉Java的预期不符。 或者: 从你的模式中删除Z ,或 向您的数据添加偏移信息(首选)。 如果您的数据是用UTC表示的时刻,那么直接附加一个字符Z (“Zulu”的缩写)。 如果意味着像印度这样的特定偏移量,请附加+05:30类的偏移量。 更好的是:继续阅读,使用新课程。 java.time Java 8带来了新的java.time包 ,取代了旧的麻烦的java.util. ...
-
使用此代码 public static String parseTodaysDate(String time) { String inputPattern = "EEE MMM d HH:mm:ss zzz yyyy"; String outputPattern = "dd-MM-yyyy"; SimpleDateFormat inputFormat = new SimpleDateFormat(inputPattern); SimpleDateFormat out ...
-
支持上午/下午的日期格式需要是'a'而不是'aa', 所以你基本上需要做DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mma"); The Date format for supporting am/pm needs to be 'a' rather than 'aa', so you bascially need to do DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mma");
-
Swagger:java.text.ParseException:不可解析的日期错误(Swagger: java.text.ParseException: Unparseable date error)[2021-12-15]
这个问题的答案已经解决。 显然,我没有在我的gradle应用程序文件中提到任何GSON版本。 所以,默认情况下它假定为2.3.1版本。 但是,我的GSON数据是2.7版本。 这就是它失败的原因。 如果我们使用Gson 2.3.1版本,则defaultdatetypeadapter.java具有以下方法 final class DefaultDateTypeAdapter implements JsonSerializer, JsonDeserializer { // T ... -
java.text.ParseException:无法解析的日期:“06-DEC-11”(java.text.ParseException: Unparseable date: “06-DEC-11”)[2022-05-14]
好的,问题是在FECData定义为new SimpleDateFormat("DD-MMM-YY") 。 根据https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html#SimpleDateFormat(java.lang.String) ,它使用给定的模式和默认日期格式构造SimpleDateFormat 默认语言环境的符号。 问题是您的(JVM)默认语言环境不是Locale.ENGLISH ,因此"06-DEC-11 ... -
如何解决java.text.ParseException:不可解析的日期?(How to solve java.text.ParseException: Unparseable date?)[2022-05-09]
你正在解析一个不是该模式的正确表示的字符串,你错过了TimeZone ...例如: -0600 例: Date date1 = df.parse("2016-11-18T11:13:43.838-0600Z"); 这里是更多信息的文档 .... 你的代码应该如下所示: DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); try { Date date1 = df.parse("2016-11 ... -
java.text.ParseException:无法解析的日期:[重复](java.text.ParseException: Unparseable date: [duplicate])[2023-04-27]
我看到你有MSK时间。 您的语言环境是英语还是俄语? 因为如果您的语言环境是俄语,则9月不是有效月份。 所以,你有两个选择: 将您的语言环境更改为英语。 让你的俄语地区,但用俄语写月份。 修改将语言环境更改为英语: SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.ENGLISH); I see that you have MSK time. Is your local ... -
改变yyyy-MM-dd HH24:mm:ss到yyyy-MM-dd HH:mm:ss 有关日期和时间模式的更多信息 Change yyyy-MM-dd HH24:mm:ss to yyyy-MM-dd HH:mm:ss More information about Date and Time Patterns
-
这应该工作,我纠正了2个错误: 首先,格式应该是yyyy-MM-dd因为这是您输入的格式。 然后,你不能隐含地将java.util.Date为java.sql.Date ,你需要使用java.sql.Date构造函数和java.util.Date#getTime() 。 看这里 解 SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); java.sql.Date SQLDate = new java.sql.Dat ...