dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29748
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15082: add method to get iso from locally formatted date string
------------------------------------------------------------
revno: 15082
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-04-29 10:50:54 +0545
message:
add method to get iso from locally formatted date string
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/AbstractCalendar.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/Calendar.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateUnit.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-api/src/main/java/org/hisp/dhis/calendar/AbstractCalendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/AbstractCalendar.java 2014-04-27 09:03:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/AbstractCalendar.java 2014-04-29 05:05:54 +0000
@@ -122,6 +122,15 @@
}
@Override
+ public DateUnit toIso( String date )
+ {
+ DateTimeFormatter format = DateTimeFormat.forPattern( defaultDateFormat() );
+ DateTime dateTime = format.parseDateTime( date );
+
+ return toIso( DateUnit.fromDateTime( dateTime ) );
+ }
+
+ @Override
public DateUnit fromIso( int year, int month, int day )
{
return fromIso( new DateUnit( year, month, day ) );
@@ -130,7 +139,7 @@
@Override
public DateUnit today()
{
- DateTime dateTime = new DateTime( ISOChronology.getInstance() );
+ DateTime dateTime = DateTime.now( ISOChronology.getInstance() );
return fromIso( DateUnit.fromDateTime( dateTime ) );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/Calendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/Calendar.java 2014-04-27 09:57:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/Calendar.java 2014-04-29 05:05:54 +0000
@@ -77,6 +77,14 @@
/**
* Convert local calendar to an ISO 8601 DateUnit.
+ * @param date Date formatted using default date format
+ * @return DateUnit representing local date in ISO 8601
+ * @see <a href="http://en.wikipedia.org/wiki/ISO_8601">http://en.wikipedia.org/wiki/ISO_8601</a>
+ */
+ DateUnit toIso( String date);
+
+ /**
+ * Convert local calendar to an ISO 8601 DateUnit.
* @param dateUnit DateUnit representing local year, month, day
* @return DateUnit representing local date in ISO 8601
* @see <a href="http://en.wikipedia.org/wiki/ISO_8601">http://en.wikipedia.org/wiki/ISO_8601</a>
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateUnit.java 2014-04-27 08:47:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateUnit.java 2014-04-29 05:05:54 +0000
@@ -33,8 +33,6 @@
import org.joda.time.chrono.ISOChronology;
import javax.validation.constraints.NotNull;
-import java.text.SimpleDateFormat;
-import java.util.Date;
/**
* Class representing a specific calendar date.