待辦事項 #1073

Date#parse を消すパッチ
啟用日期: 2003-01-20 19:35 最後更新: 2003-01-21 12:56

回報者:
(匿名)
負責人:
(無)
類型:
狀態:
開啟
元件:
(無)
里程碑:
(無)
優先權:
5 - 中
嚴重程度:
5 - 中
處理結果:
檔案:
1

細節

「メソッド parse(String) は型 Date で使用すべきではあり
ません。」がうざい方はどうぞ。

Ticket History (2/2 Histories)

2003-01-20 19:35 Updated by: None
  • File 302: dateparse.patch is attached
2003-01-21 12:56 Updated by: None
評語
Logged In: NO

すいません。
実行ファイルも黙ってしまいます。
修正パッチです。

Index: monalipse/server/LinkedObject.java
===================================================================
RCS file:
/cvsroot/monalipse/monalipse.plugin/src/monalipse/server/LinkedObject.java,v
retrieving revision 1.4
diff -u -r1.4 LinkedObject.java
--- monalipse/server/LinkedObject.java 21 Dec 2002
12:43:22 -0000 1.4
+++ monalipse/server/LinkedObject.java 21 Jan 2003 03:53:57
-0000
@@ -15,11 +15,14 @@
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.UnknownHostException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.logging.Logger;

@@ -29,6 +32,7 @@
import javax.imageio.stream.ImageInputStream;

import monalipse.MonalipsePlugin;
+
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.eclipse.core.resources.IFile;
@@ -219,12 +223,13 @@
out.close();
logger.finest("complete");
long mod = 0;
- try
- {
- mod =
Date.parse(get.getResponseHeader("Last-Modified").getValue());
- }
- catch (RuntimeException e)
- {
+ try {
+ String s =
get.getResponseHeader("Last-Modified").getValue();
+ DateFormat fmt = new SimpleDateFormat("EEE, d MMM
yyyy HH:mm:ss z", Locale.US);
+ Date d = fmt.parse(s);
+ mod = d.getTime();
+ } catch (Exception e) {
+ e.printStackTrace();
}
final long lastModified = mod;
final byte[] bytes = out.toByteArray();
Index: monalipse/server/giko/ThreadContentProvider.java
===================================================================
RCS file:
/cvsroot/monalipse/monalipse.plugin/src/monalipse/server/giko/ThreadContentProvider.java,v
retrieving revision 1.17
diff -u -r1.17 ThreadContentProvider.java
--- monalipse/server/giko/ThreadContentProvider.java 19 Jan
2003 15:26:47 -0000 1.17
+++ monalipse/server/giko/ThreadContentProvider.java 21 Jan
2003 03:53:59 -0000
@@ -14,10 +14,13 @@
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.logging.Logger;
import java.util.regex.Matcher;
@@ -883,12 +886,13 @@
contentRange = cin.getRange();
monitor.getRunner().run(null, this);

- try
- {
- serverTime =
Date.parse(method.getResponseHeader("Date").getValue()) / 1000;
- }
- catch (RuntimeException e)
- {
+ try {
+ String s = method.getResponseHeader("Date").getValue();
+ DateFormat fmt = new SimpleDateFormat("EEE, d MMM yyyy
HH:mm:ss z", Locale.US);
+ Date d = fmt.parse(s);
+ serverTime = d.getTime() / 1000;
+ } catch (Exception e) {
+ e.printStackTrace();
}
}

Attachment File List

編輯

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » 登入