A small problem encountered in SimpleDateFormt

xiaoxiao2021-03-06  77

One problem to consider when doing ProxyServer is to compare two times of the client's if-modified-since and server-only Last-Modified, if you use Java, it is more convenient, but there are some small problems that must be noted. Otherwise, your own proxy is always no problem on some machines, but in some machines can't.

The root of the problem is a small negligence that constructs SimpleDateFormat, usually our construct is like this:

SimpleDateFormat DF = New SimpleDateFormat ("Eee, DD MMM YYYY HH: MM: SS Z"); // I buried hidden dangers

Because DateFormat is the class of local-sensitive, if there is no corresponding Locale when constructing the object, it may not be able to perform the resolution. Which machine can analyze which cannot be set up, it is constructed. This Locale-Sensitive does not forget to specify Locale, like Numberformat.

But when doing ProxyServer, several DFs have failed:

DF = New SimpleDateFormat ("Eeeeee, DD-MMM-YY HH: MM: SS Z", Java.util.Locale.china); DF = New SimpleDateFormat ("Eeeeee, DD-MMM-YY HH: mm: SS Z" , java.util.locale.prc); I don't know why it is only possible to correctly parse the region, even if the domestic website is not good, it is puzzled.

转载请注明原文地址:https://www.9cbs.com/read-91843.html

New Post(0)