From 0a3094d132aeec1f1b6c8635e6567c8e01dcd00e Mon Sep 17 00:00:00 2001 From: yukihane Date: Fri, 19 Aug 2011 08:48:59 +0900 Subject: [PATCH] =?utf8?q?=E9=81=8E=E5=8E=BB=E3=83=AD=E3=82=B0=E8=A6=81?= =?utf8?q?=E6=B1=82=E6=99=82=E3=81=AB=E6=8C=87=E5=AE=9A=E3=81=99=E3=82=8Bw?= =?utf8?q?hen=E5=80=A4=E3=82=92=E5=86=85=E9=83=A8=E7=9A=84=E3=81=AB?= =?utf8?q?=E3=81=AFlong=E3=81=A7=E4=BF=9D=E6=8C=81=E3=81=99=E3=82=8B?= =?utf8?q?=E3=82=88=E3=81=86=E5=A4=89=E6=9B=B4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../saccubus/converter/filegetter/WebFileInstanciator.java | 2 +- frontend/src/saccubus/net/CommentInfo.java | 6 +++--- frontend/src/saccubus/util/WayBackTimeParser.java | 8 ++++---- frontend/test/saccubus/util/WayBackTimeParserTest.java | 12 ++++++------ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/frontend/src/saccubus/converter/filegetter/WebFileInstanciator.java b/frontend/src/saccubus/converter/filegetter/WebFileInstanciator.java index 19c4343..0401729 100644 --- a/frontend/src/saccubus/converter/filegetter/WebFileInstanciator.java +++ b/frontend/src/saccubus/converter/filegetter/WebFileInstanciator.java @@ -56,7 +56,7 @@ public class WebFileInstanciator extends FileInstanciator { videoInfo = client.getVideoInfo(tag); if (StringUtils.isNotBlank(time)) { System.out.print("Setting wayback time..."); - final String waybacktime = WayBackTimeParser.parse(time); + final long waybacktime = WayBackTimeParser.parse(time); String waybackkey = client.getWayBackKey(videoInfo); commentInfo = new CommentInfo(waybackkey, waybacktime); }else{ diff --git a/frontend/src/saccubus/net/CommentInfo.java b/frontend/src/saccubus/net/CommentInfo.java index 790d4c1..3a35556 100644 --- a/frontend/src/saccubus/net/CommentInfo.java +++ b/frontend/src/saccubus/net/CommentInfo.java @@ -7,9 +7,9 @@ package saccubus.net; public class CommentInfo { private final String wayBackKey; - private final String wayBackTime; + private final long wayBackTime; - public CommentInfo(String wayBackKey, String wayBackTime) { + public CommentInfo(String wayBackKey, long wayBackTime) { this.wayBackKey = wayBackKey; this.wayBackTime = wayBackTime; } @@ -18,7 +18,7 @@ public class CommentInfo { return wayBackKey; } - public String getWayBackTime() { + public long getWayBackTime() { return wayBackTime; } } diff --git a/frontend/src/saccubus/util/WayBackTimeParser.java b/frontend/src/saccubus/util/WayBackTimeParser.java index 8df9342..69a3f35 100644 --- a/frontend/src/saccubus/util/WayBackTimeParser.java +++ b/frontend/src/saccubus/util/WayBackTimeParser.java @@ -32,10 +32,10 @@ public final class WayBackTimeParser { * @return パース結果. * @throws IOException パース失敗. */ - public static String parse(String time) throws IOException { + public static long parse(String time) throws IOException { final Matcher mNumber = PATTERN_NUMBER.matcher(time); if (mNumber.matches()) { - return time; + return Long.parseLong(time); } final Matcher mHMS = PATTERN_YYMMDD_HH_MM_SS.matcher(time); @@ -48,7 +48,7 @@ public final class WayBackTimeParser { str.append(":"); } final Date date = fmt.parse(str.toString()); - return Long.toString(date.getTime() / 1000); + return date.getTime() / 1000; } catch (ParseException ex) { throw new IOException("Cannot parse wayback time: " + time, ex); } @@ -64,7 +64,7 @@ public final class WayBackTimeParser { str.append(":"); } final Date date = fmt.parse(str.toString()); - return Long.toString(date.getTime() / 1000); + return date.getTime() / 1000; } catch (ParseException ex) { throw new IOException("Cannot parse wayback time: " + time, ex); } diff --git a/frontend/test/saccubus/util/WayBackTimeParserTest.java b/frontend/test/saccubus/util/WayBackTimeParserTest.java index 69874e0..5d64ec5 100644 --- a/frontend/test/saccubus/util/WayBackTimeParserTest.java +++ b/frontend/test/saccubus/util/WayBackTimeParserTest.java @@ -14,8 +14,8 @@ public class WayBackTimeParserTest { @Test public void testParseYYYYMMDD_H_M_S() throws IOException { final String text = "2011/08/19 00:00:12"; - final String expected = "1313679612"; - final String actual = WayBackTimeParser.parse(text); + final long expected = 1313679612L; + final long actual = WayBackTimeParser.parse(text); assertEquals(expected, actual); } @@ -23,8 +23,8 @@ public class WayBackTimeParserTest { @Test public void testParseYYYYMMDD_H_M() throws IOException { final String text = "2011/08/19 00:00"; - final String expected = "1313679600"; - final String actual = WayBackTimeParser.parse(text); + final long expected = 1313679600L; + final long actual = WayBackTimeParser.parse(text); assertEquals(expected, actual); } @@ -32,7 +32,7 @@ public class WayBackTimeParserTest { @Test public void testParseNumber() throws IOException { final String text = "1313679600"; - final String actual = WayBackTimeParser.parse(text); - assertEquals(text, actual); + final long actual = WayBackTimeParser.parse(text); + assertEquals(Long.parseLong(text), actual); } } -- 2.11.0