dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36187
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18531: use DateUtils.parseDate in Op, adds support for more formats, and also simplifies the code a bit
------------------------------------------------------------
revno: 18531
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-03-09 12:23:04 +0530
message:
use DateUtils.parseDate in Op, adds support for more formats, and also simplifies the code a bit
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/objectfilter/ops/Op.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-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/objectfilter/ops/Op.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/objectfilter/ops/Op.java 2015-02-20 08:28:01 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/objectfilter/ops/Op.java 2015-03-09 06:53:04 +0000
@@ -28,7 +28,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.text.SimpleDateFormat;
+import org.hisp.dhis.system.util.DateUtils;
+
import java.util.Date;
/**
@@ -38,18 +39,6 @@
{
private String value;
- private static SimpleDateFormat[] simpleDateFormats = new SimpleDateFormat[]{
- new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssZ" ),
- new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss" ),
- new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm" ),
- new SimpleDateFormat( "yyyy-MM-dd'T'HH" ),
- new SimpleDateFormat( "yyyy-MM-dd" ),
- new SimpleDateFormat( "yyyy-MM" ),
- new SimpleDateFormat( "yyyyMMdd" ),
- new SimpleDateFormat( "yyyyMM" ),
- new SimpleDateFormat( "yyyy" )
- };
-
public boolean wantValue()
{
return true;
@@ -115,16 +104,7 @@
}
else if ( Date.class.isAssignableFrom( klass ) )
{
- for ( SimpleDateFormat simpleDateFormat : simpleDateFormats )
- {
- try
- {
- return (T) simpleDateFormat.parse( value );
- }
- catch ( Exception ignored )
- {
- }
- }
+ return (T) DateUtils.parseDate( value );
}
return null;