Revision: 4477
          http://vexi.svn.sourceforge.net/vexi/?rev=4477&view=rev
Author:   mkpg2
Date:     2013-01-13 05:38:40 +0000 (Sun, 13 Jan 2013)
Log Message:
-----------
Fix. Instant.compareTo(), inverted return.
Fix. Instant.parse()/format(). Not taking into account Calendar.MONTH starts 
from 0.

Modified Paths:
--------------
    trunk/org.vexi-library.value/src/main/java/org/vexi/value/Instant.java
    trunk/org.vexi-library.value/src/test/java/org/vexi/value/TestDate.java
    trunk/org.vexi-library.value/src/test/java/org/vexi/value/TestInstant.java

Modified: trunk/org.vexi-library.value/src/main/java/org/vexi/value/Instant.java
===================================================================
--- trunk/org.vexi-library.value/src/main/java/org/vexi/value/Instant.java      
2013-01-13 00:46:29 UTC (rev 4476)
+++ trunk/org.vexi-library.value/src/main/java/org/vexi/value/Instant.java      
2013-01-13 05:38:40 UTC (rev 4477)
@@ -62,7 +62,7 @@
                        
                        // month
                        if(getIntLength(s, cursor)!=2) return null;
-                       c.set(Calendar.MONTH, getInt(s, cursor));
+                       c.set(Calendar.MONTH, getInt(s, cursor)-1);
                        cursor+=3;
                        
                        // day
@@ -137,7 +137,7 @@
        StringBuffer r = new StringBuffer();
        r.append(zeroPad(4,c.get(Calendar.YEAR)));
        r.append("-");
-       r.append(zeroPad(2,c.get(Calendar.MONTH)));
+       r.append(zeroPad(2,c.get(Calendar.MONTH)+1));
        r.append("-");
        r.append(zeroPad(2,c.get(Calendar.DAY_OF_MONTH)));
        r.append(" ");
@@ -158,9 +158,11 @@
     }
     public int compareTo(Object obj) {
         Instant b = (Instant)obj;
-        if(value>b.value) return -1;
-        if(value<b.value) return 1;
+        if(value>b.value) return 1;
+        if(value<b.value) return -1;
         return 0;
     }
 
+       public long millis() { return value; }
+
 }

Modified: 
trunk/org.vexi-library.value/src/test/java/org/vexi/value/TestDate.java
===================================================================
--- trunk/org.vexi-library.value/src/test/java/org/vexi/value/TestDate.java     
2013-01-13 00:46:29 UTC (rev 4476)
+++ trunk/org.vexi-library.value/src/test/java/org/vexi/value/TestDate.java     
2013-01-13 05:38:40 UTC (rev 4477)
@@ -70,4 +70,8 @@
         assertEquals(50, Date.newYM(2011,11).diff(Date.PART_MONTH, 
Date.newYM(2007, 9)));
         assertEquals(22, Date.newYQ(2008,1).diff(Date.PART_QUARTER, 
Date.newYQ(2002, 3)));
     }
+    
+    public void testCompare() throws ValueException {
+       assertEquals(Date.newY(2000).compareTo(Date.newY(1999)), new 
Long(2000).compareTo(new Long(1999)));
+    }
 }

Modified: 
trunk/org.vexi-library.value/src/test/java/org/vexi/value/TestInstant.java
===================================================================
--- trunk/org.vexi-library.value/src/test/java/org/vexi/value/TestInstant.java  
2013-01-13 00:46:29 UTC (rev 4476)
+++ trunk/org.vexi-library.value/src/test/java/org/vexi/value/TestInstant.java  
2013-01-13 05:38:40 UTC (rev 4477)
@@ -9,7 +9,7 @@
        static String ts0 = "2014-01-12 21:30:00";
        static String ts1 = "2013-01-12 22:22:00";
        public void testFormat() throws ValueException {
-               assertEquals("1970-01-01 01:00:00.0",i0.format());
+               assertEquals("1970-01-01 01:00:00",i0.format());
                assertEquals("1970-04-26 18:46:39.999",i1.format());
        }
 
@@ -28,4 +28,8 @@
        public void testDiff() throws ValueException {
                assertEquals(9999999999l,i1.diff(i0));
        }    
+       
+       public void testCompare() throws ValueException {
+               assertEquals(i0.compareTo(i1), new 
Long(i0.millis()).compareTo(new Long(i1.millis())));         
+       }   
 }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_123012
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to