commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1294760 - /commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java
Date Tue, 28 Feb 2012 18:31:57 GMT
Author: sebb
Date: Tue Feb 28 18:31:57 2012
New Revision: 1294760

URL: http://svn.apache.org/viewvc?rev=1294760&view=rev
Log:
Clone calendar to ensure original settings are preserved.
[Previously, the hour was not reset]

Modified:
    commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java

Modified: commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java?rev=1294760&r1=1294759&r2=1294760&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java
(original)
+++ commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java
Tue Feb 28 18:31:57 2012
@@ -62,13 +62,14 @@ public class FTPTimestampParserImplTest 
 
     public void testParseTimestampWithSlop() {
         Calendar cal = Calendar.getInstance();
-        cal.add(Calendar.HOUR_OF_DAY, 1);
         cal.set(Calendar.SECOND,0);
         cal.set(Calendar.MILLISECOND,0);
-        Date anHourFromNow = cal.getTime();
-        cal.add(Calendar.DATE, 1);
-        Date anHourFromNowTomorrow = cal.getTime();
-        cal.add(Calendar.DATE, -1);
+
+        Calendar caltemp = (Calendar) cal.clone();
+        caltemp.add(Calendar.HOUR_OF_DAY, 1);
+        Date anHourFromNow = caltemp.getTime();
+        caltemp.add(Calendar.DATE, 1);
+        Date anHourFromNowTomorrow = caltemp.getTime();
 
         FTPTimestampParserImpl parser = new FTPTimestampParserImpl();
 



Mime
View raw message