← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12062: Removed method in DateUtils which did not make much sense

 

------------------------------------------------------------
revno: 12062
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-09-12 12:06:37 +0200
message:
  Removed method in DateUtils which did not make much sense
modified:
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ExcelUtils.java
  dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/DateUtilsTest.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java	2013-09-12 10:06:37 +0000
@@ -399,36 +399,6 @@
     }
 
     /**
-     * This method converts a string from the date format "yyyy-MM-dd" to
-     * "dd-MMM-yyyy".
-     * 
-     * @param date is the string to be converted.
-     * @return converted string if the date is valid, else the original string
-     *         is returned
-     */
-    public static String convertDate( String dateString )
-    {
-        if ( !dateIsValid( dateString ) )
-        {
-            return dateString;
-        }
-
-        SimpleDateFormat dateFormat = new SimpleDateFormat( DEFAULT_DATE_FORMAT );
-
-        try
-        {
-            Date date = dateFormat.parse( dateString );
-            dateFormat.applyPattern( "dd MMM yyyy" );
-
-            return dateFormat.format( date );
-        }
-        catch ( ParseException pe )
-        {
-            throw new RuntimeException( "Date string could not be parsed: " + dateString );
-        }
-    }
-
-    /**
      * This method adds days to a date
      * 
      * @param date the date.

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ExcelUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ExcelUtils.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ExcelUtils.java	2013-09-12 10:06:37 +0000
@@ -225,8 +225,9 @@
         {
             for ( GridHeader col : grid.getVisibleHeaders() )
             {
-                sheet.addCell( new Label( column++, 3, i18n.getString( DateUtils.convertDate( col.getName() ) ),
-                    cellFormat ) );
+                //TODO use i18nFormat.formatDate for label
+                
+                sheet.addCell( new Label( column++, 3, col.getName(), cellFormat ) );
             }
         }
         catch ( RowsExceededException e )

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/DateUtilsTest.java'
--- dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/DateUtilsTest.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/DateUtilsTest.java	2013-09-12 10:06:37 +0000
@@ -28,11 +28,9 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.junit.Assert.assertEquals;
+import static org.hisp.dhis.system.util.DateUtils.dateIsValid;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-import static org.hisp.dhis.system.util.DateUtils.convertDate;
-import static org.hisp.dhis.system.util.DateUtils.dateIsValid;
 
 import org.junit.Test;
 
@@ -51,12 +49,4 @@
         assertFalse( dateIsValid( "2000-03-40" ) );
         assertFalse( dateIsValid( "20d20-03-01" ) );
     }
-    
-    @Test
-    public void testConvertDate()
-    {
-        assertEquals( "20 apr 2009", convertDate( "2009-04-20" ).toLowerCase() );
-        assertEquals( "10 mar 2010", convertDate( "2010-03-10" ).toLowerCase() );
-        assertEquals( "Invalid", convertDate( "Invalid" ) );
-    }
 }