dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32458
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16560: introduce timing information in DateUnit (renamed DateTimeUnit), removed old timing classes, wip
------------------------------------------------------------
revno: 16560
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-08-29 17:02:21 +0700
message:
introduce timing information in DateUnit (renamed DateTimeUnit), removed old timing classes, wip
removed:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateUnit.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/TimeUnit.java
dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateUnitPeriodTypeParserTest.java
dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateUnitTest.java
dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateUnitTypeTest.java
dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/TimeUnitTest.java
added:
dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateTimeUnitPeriodTypeParserTest.java
dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateTimeUnitTest.java
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/ChronologyBasedCalendar.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateInterval.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateTimeUnit.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateUnitPeriodTypeParser.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/NepaliCalendar.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/BiMonthlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Cal.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/CalendarPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialAprilPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialJulyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialOctoberPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAbstractPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAprilPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.java
dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/impl/NepaliCalendarTest.java
dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/RelativePeriodTest.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/AddDataElementCategoryOptionAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/UpdateDataElementCategoryOptionAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/ShowAddOrganisationUnitFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.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-08-08 07:44:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/AbstractCalendar.java 2014-08-29 10:02:21 +0000
@@ -107,52 +107,52 @@
}
@Override
- public String formattedDate( DateUnit dateUnit )
+ public String formattedDate( DateTimeUnit dateTimeUnit )
{
return getDateFormat()
- .replace( "yyyy", String.format( "%04d", dateUnit.getYear() ) )
- .replace( "MM", String.format( "%02d", dateUnit.getMonth() ) )
- .replace( "dd", String.format( "%02d", dateUnit.getDay() ) );
+ .replace( "yyyy", String.format( "%04d", dateTimeUnit.getYear() ) )
+ .replace( "MM", String.format( "%02d", dateTimeUnit.getMonth() ) )
+ .replace( "dd", String.format( "%02d", dateTimeUnit.getDay() ) );
}
@Override
- public String formattedDate( String dateFormat, DateUnit dateUnit )
+ public String formattedDate( String dateFormat, DateTimeUnit dateTimeUnit )
{
return dateFormat
- .replace( "yyyy", String.format( "%04d", dateUnit.getYear() ) )
- .replace( "MM", String.format( "%02d", dateUnit.getMonth() ) )
- .replace( "dd", String.format( "%02d", dateUnit.getDay() ) );
+ .replace( "yyyy", String.format( "%04d", dateTimeUnit.getYear() ) )
+ .replace( "MM", String.format( "%02d", dateTimeUnit.getMonth() ) )
+ .replace( "dd", String.format( "%02d", dateTimeUnit.getDay() ) );
}
@Override
- public String formattedIsoDate( DateUnit dateUnit )
+ public String formattedIsoDate( DateTimeUnit dateTimeUnit )
{
- dateUnit = toIso( dateUnit );
- DateTime dateTime = dateUnit.toDateTime();
+ dateTimeUnit = toIso( dateTimeUnit );
+ DateTime dateTime = dateTimeUnit.toDateTime();
DateTimeFormatter format = DateTimeFormat.forPattern( getDateFormat() );
return format.print( dateTime );
}
@Override
- public DateUnit toIso( int year, int month, int day )
+ public DateTimeUnit toIso( int year, int month, int day )
{
- return toIso( new DateUnit( year, month, day ) );
+ return toIso( new DateTimeUnit( year, month, day ) );
}
@Override
- public DateUnit toIso( String date )
+ public DateTimeUnit toIso( String date )
{
DateTimeFormatter format = DateTimeFormat.forPattern( getDateFormat() );
DateTime dateTime = format.parseDateTime( date );
- return toIso( DateUnit.fromDateTime( dateTime ) );
+ return toIso( DateTimeUnit.fromJodaDateTime( dateTime ) );
}
@Override
- public DateUnit fromIso( int year, int month, int day )
+ public DateTimeUnit fromIso( int year, int month, int day )
{
- return fromIso( new DateUnit( year, month, day, true ) );
+ return fromIso( new DateTimeUnit( year, month, day, true ) );
}
@Override
@@ -162,9 +162,9 @@
}
@Override
- public DateInterval toInterval( DateUnit dateUnit, DateIntervalType type )
+ public DateInterval toInterval( DateTimeUnit dateTimeUnit, DateIntervalType type )
{
- return toInterval( dateUnit, type, 0, 1 );
+ return toInterval( dateTimeUnit, type, 0, 1 );
}
@Override
@@ -174,24 +174,24 @@
}
@Override
- public List<DateInterval> toIntervals( DateUnit dateUnit, DateIntervalType type, int offset, int length, int periods )
+ public List<DateInterval> toIntervals( DateTimeUnit dateTimeUnit, DateIntervalType type, int offset, int length, int periods )
{
List<DateInterval> dateIntervals = Lists.newArrayList();
for ( int i = offset; i <= (offset + periods - 1); i++ )
{
- dateIntervals.add( toInterval( dateUnit, type, i, length ) );
+ dateIntervals.add( toInterval( dateTimeUnit, type, i, length ) );
}
return dateIntervals;
}
@Override
- public DateUnit today()
+ public DateTimeUnit today()
{
DateTime dateTime = DateTime.now( ISOChronology.getInstance() );
- DateUnit dateUnit = new DateUnit( dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), true );
- return fromIso( dateUnit );
+ DateTimeUnit dateTimeUnit = new DateTimeUnit( dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), true );
+ return fromIso( dateTimeUnit );
}
@Override
=== 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-08-08 07:44:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/Calendar.java 2014-08-29 10:02:21 +0000
@@ -34,7 +34,7 @@
* Generic interface for representing a Calendar.
*
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- * @see DateUnit
+ * @see DateTimeUnit
* @see DateInterval
* @see DateIntervalType
*/
@@ -64,30 +64,30 @@
/**
* Formats dateUnit using dateFormat
*
- * @param dateUnit DateUnit representing local year, month, day
+ * @param dateTimeUnit DateUnit representing local year, month, day
* @return Default date format
* @see #getDateFormat()
*/
- String formattedDate( DateUnit dateUnit );
+ String formattedDate( DateTimeUnit dateTimeUnit );
/**
* Formats dateUnit using supplied date format
*
* @param dateFormat Date format to use
- * @param dateUnit DateUnit representing local year, month, day
+ * @param dateTimeUnit DateUnit representing local year, month, day
* @return Default date format
* @see #getDateFormat()
*/
- String formattedDate( String dateFormat, DateUnit dateUnit );
+ String formattedDate( String dateFormat, DateTimeUnit dateTimeUnit );
/**
* Formats dateUnit using dateFormat and ISO 8601
*
- * @param dateUnit DateUnit representing local year, month, day
+ * @param dateTimeUnit DateUnit representing local year, month, day
* @return Default date format
* @see #getDateFormat()
*/
- String formattedIsoDate( DateUnit dateUnit );
+ String formattedIsoDate( DateTimeUnit dateTimeUnit );
/**
* Convert local calendar to an ISO 8601 DateUnit.
@@ -98,7 +98,7 @@
* @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( int year, int month, int day );
+ DateTimeUnit toIso( int year, int month, int day );
/**
* Convert local calendar to an ISO 8601 DateUnit.
@@ -107,16 +107,16 @@
* @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 );
+ DateTimeUnit toIso( String date );
/**
* Convert local calendar to an ISO 8601 DateUnit.
*
- * @param dateUnit DateUnit representing local year, month, day
+ * @param dateTimeUnit 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>
*/
- DateUnit toIso( DateUnit dateUnit );
+ DateTimeUnit toIso( DateTimeUnit dateTimeUnit );
/**
* Convert from local to ISO 8601 DateUnit.
@@ -127,38 +127,38 @@
* @return DateUnit representing ISO 8601 in local
* @see <a href="http://en.wikipedia.org/wiki/ISO_8601">http://en.wikipedia.org/wiki/ISO_8601</a>
*/
- DateUnit fromIso( int year, int month, int day );
+ DateTimeUnit fromIso( int year, int month, int day );
/**
* Convert from local to ISO 8601 DateUnit.
*
- * @param dateUnit DateUnit representing ISO 8601 year, month, day
+ * @param dateTimeUnit DateUnit representing ISO 8601 year, month, day
* @return DateUnit representing ISO 8601 in local
* @see <a href="http://en.wikipedia.org/wiki/ISO_8601">http://en.wikipedia.org/wiki/ISO_8601</a>
*/
- DateUnit fromIso( DateUnit dateUnit );
+ DateTimeUnit fromIso( DateTimeUnit dateTimeUnit );
/**
* Gets interval of type based on DateUnit
*
- * @param dateUnit DateUnit representing local year, month, day
+ * @param dateTimeUnit DateUnit representing local year, month, day
* @param type Interval type to get
* @param offset Offset to start at, can be negative of positive
* @param length How many periods to asks for, i.e. type = MONTH, length = 2, two months
* @return Interval for interval type based on dateUnit
* @see DateIntervalType
*/
- DateInterval toInterval( DateUnit dateUnit, DateIntervalType type, int offset, int length );
+ DateInterval toInterval( DateTimeUnit dateTimeUnit, DateIntervalType type, int offset, int length );
/**
* Gets interval of type based on DateUnit using default options, 0 for offset, 1 for length
*
- * @param dateUnit DateUnit representing local year, month, day
+ * @param dateTimeUnit DateUnit representing local year, month, day
* @param type Interval type to get
* @return Interval for interval type based on dateUnit
* @see DateIntervalType
*/
- DateInterval toInterval( DateUnit dateUnit, DateIntervalType type );
+ DateInterval toInterval( DateTimeUnit dateTimeUnit, DateIntervalType type );
/**
* Gets interval of type based on today's date
@@ -183,7 +183,7 @@
/**
* Gets interval of type based on DateUnit
*
- * @param dateUnit DateUnit representing local year, month, day
+ * @param dateTimeUnit DateUnit representing local year, month, day
* @param type Interval type to get
* @param offset Offset to start at, can be negative of positive
* @param length How many periods to asks for, i.e. type = MONTH, length = 2, two months
@@ -191,14 +191,14 @@
* @return Interval for interval type based on dateUnit
* @see DateIntervalType
*/
- List<DateInterval> toIntervals( DateUnit dateUnit, DateIntervalType type, int offset, int length, int periods );
+ List<DateInterval> toIntervals( DateTimeUnit dateTimeUnit, DateIntervalType type, int offset, int length, int periods );
/**
* Gets current date as local DateUnit
*
* @return Today date as local DateUnit
*/
- DateUnit today();
+ DateTimeUnit today();
/**
* Gets the number of months in a calendar year.
@@ -239,42 +239,42 @@
* Gets week number using local DateUnit, week number is calculated based on
* ISO 8601 week numbers
*
- * @param dateUnit DateUnit representing local year, month, day
+ * @param dateTimeUnit DateUnit representing local year, month, day
* @return Week number
* @see <a href="http://en.wikipedia.org/wiki/ISO_8601">http://en.wikipedia.org/wiki/ISO_8601</a>
* @see <a href="http://en.wikipedia.org/wiki/ISO_week_date">http://en.wikipedia.org/wiki/ISO_week_date</a>
*/
- int isoWeek( DateUnit dateUnit );
+ int isoWeek( DateTimeUnit dateTimeUnit );
/**
* Returns week number using local DateUnit, week number is calculated based on local calendar.
*
- * @param dateUnit DateUnit representing local year, month, day
+ * @param dateTimeUnit DateUnit representing local year, month, day
* @return Week number
*/
- int week( DateUnit dateUnit );
+ int week( DateTimeUnit dateTimeUnit );
/**
* Gets the ISO 8601 weekday for this local DateUnit, using ISO 8601 day numbering,
* 1=Monday => 7=Sunday.
*
- * @param dateUnit DateUnit representing local year, month, day
+ * @param dateTimeUnit DateUnit representing local year, month, day
* @return Weekday number
* @see <a href="http://en.wikipedia.org/wiki/ISO_8601">http://en.wikipedia.org/wiki/ISO_8601</a>
* @see <a href="http://en.wikipedia.org/wiki/ISO_week_date">http://en.wikipedia.org/wiki/ISO_week_date</a>
*/
- int isoWeekday( DateUnit dateUnit );
+ int isoWeekday( DateTimeUnit dateTimeUnit );
/**
* Gets the local weekday for this local DateUnit, using ISO 8601 day numbering,
* 1=Monday => 7=Sunday.
*
- * @param dateUnit DateUnit representing local year, month, day
+ * @param dateTimeUnit DateUnit representing local year, month, day
* @return Weekday number
* @see <a href="http://en.wikipedia.org/wiki/ISO_8601">http://en.wikipedia.org/wiki/ISO_8601</a>
* @see <a href="http://en.wikipedia.org/wiki/ISO_week_date">http://en.wikipedia.org/wiki/ISO_week_date</a>
*/
- int weekday( DateUnit dateUnit );
+ int weekday( DateTimeUnit dateTimeUnit );
/**
* Gets the (untranslated) I18n key for local month
@@ -315,72 +315,72 @@
/**
* Returns a new dateUnit with specified number of days added
*
- * @param dateUnit DateUnit representing local year, month, day
+ * @param dateTimeUnit DateUnit representing local year, month, day
* @param days Days to add
* @return dateUnit + days
*/
- DateUnit plusDays( DateUnit dateUnit, int days );
+ DateTimeUnit plusDays( DateTimeUnit dateTimeUnit, int days );
/**
* Returns a new dateUnit with specified number of days subtracted
*
- * @param dateUnit DateUnit representing local year, month, day
+ * @param dateTimeUnit DateUnit representing local year, month, day
* @param days Days to subtract
* @return dateUnit - days
*/
- DateUnit minusDays( DateUnit dateUnit, int days );
+ DateTimeUnit minusDays( DateTimeUnit dateTimeUnit, int days );
/**
* Returns a new dateUnit with specified number of weeks added
*
- * @param dateUnit DateUnit representing local year, month, day
+ * @param dateTimeUnit DateUnit representing local year, month, day
* @param weeks Weeks to add
* @return dateUnit + weeks
*/
- DateUnit plusWeeks( DateUnit dateUnit, int weeks );
+ DateTimeUnit plusWeeks( DateTimeUnit dateTimeUnit, int weeks );
/**
* Returns a new dateUnit with specified number of weeks subtracted
*
- * @param dateUnit DateUnit representing local year, month, day
+ * @param dateTimeUnit DateUnit representing local year, month, day
* @param weeks Weeks to subtract
* @return dateUnit - weeks
*/
- DateUnit minusWeeks( DateUnit dateUnit, int weeks );
+ DateTimeUnit minusWeeks( DateTimeUnit dateTimeUnit, int weeks );
/**
* Returns a new dateUnit with specified number of months added
*
- * @param dateUnit DateUnit representing local year, month, day
+ * @param dateTimeUnit DateUnit representing local year, month, day
* @param months Months to add
* @return dateUnit + months
*/
- DateUnit plusMonths( DateUnit dateUnit, int months );
+ DateTimeUnit plusMonths( DateTimeUnit dateTimeUnit, int months );
/**
* Returns a new dateUnit with specified number of months subtracted
*
- * @param dateUnit DateUnit representing local year, month, day
+ * @param dateTimeUnit DateUnit representing local year, month, day
* @param months Months to subtract
* @return dateUnit - months
*/
- DateUnit minusMonths( DateUnit dateUnit, int months );
+ DateTimeUnit minusMonths( DateTimeUnit dateTimeUnit, int months );
/**
* Returns a new dateUnit with specified number of years added
*
- * @param dateUnit DateUnit representing local year, month, day
+ * @param dateTimeUnit DateUnit representing local year, month, day
* @param years Years to add
* @return dateUnit + years
*/
- DateUnit plusYears( DateUnit dateUnit, int years );
+ DateTimeUnit plusYears( DateTimeUnit dateTimeUnit, int years );
/**
* Returns a new dateUnit with specified number of years subtracted
*
- * @param dateUnit DateUnit representing local year, month, day
+ * @param dateTimeUnit DateUnit representing local year, month, day
* @param years Years to subtract
* @return dateUnit - years
*/
- DateUnit minusYears( DateUnit dateUnit, int years );
+ DateTimeUnit minusYears( DateTimeUnit dateTimeUnit, int years );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/ChronologyBasedCalendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/ChronologyBasedCalendar.java 2014-08-28 13:10:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/ChronologyBasedCalendar.java 2014-08-29 10:02:21 +0000
@@ -45,54 +45,54 @@
}
@Override
- public DateUnit toIso( DateUnit dateUnit )
+ public DateTimeUnit toIso( DateTimeUnit dateTimeUnit )
{
- if ( dateUnit.isIso8601() )
+ if ( dateTimeUnit.isIso8601() )
{
- return dateUnit;
+ return dateTimeUnit;
}
- DateTime dateTime = dateUnit.toDateTime( chronology );
+ DateTime dateTime = dateTimeUnit.toJodaDateTime( chronology );
dateTime = dateTime.withChronology( ISOChronology.getInstance() );
- return new DateUnit( DateUnit.fromDateTime( dateTime ), true );
+ return new DateTimeUnit( DateTimeUnit.fromJodaDateTime( dateTime ), true );
}
@Override
- public DateUnit fromIso( DateUnit dateUnit )
+ public DateTimeUnit fromIso( DateTimeUnit dateTimeUnit )
{
- if ( !dateUnit.isIso8601() )
+ if ( !dateTimeUnit.isIso8601() )
{
- return dateUnit;
+ return dateTimeUnit;
}
- DateTime dateTime = dateUnit.toDateTime( ISOChronology.getInstance() );
+ DateTime dateTime = dateTimeUnit.toJodaDateTime( ISOChronology.getInstance() );
dateTime = dateTime.withChronology( chronology );
- return DateUnit.fromDateTime( dateTime );
+ return DateTimeUnit.fromJodaDateTime( dateTime );
}
@Override
- public DateInterval toInterval( DateUnit dateUnit, DateIntervalType type, int offset, int length )
+ public DateInterval toInterval( DateTimeUnit dateTimeUnit, DateIntervalType type, int offset, int length )
{
switch ( type )
{
case ISO8601_YEAR:
- return toYearIsoInterval( dateUnit, offset, length );
+ return toYearIsoInterval( dateTimeUnit, offset, length );
case ISO8601_MONTH:
- return toMonthIsoInterval( dateUnit, offset, length );
+ return toMonthIsoInterval( dateTimeUnit, offset, length );
case ISO8601_WEEK:
- return toWeekIsoInterval( dateUnit, offset, length );
+ return toWeekIsoInterval( dateTimeUnit, offset, length );
case ISO8601_DAY:
- return toDayIsoInterval( dateUnit, offset, length );
+ return toDayIsoInterval( dateTimeUnit, offset, length );
}
return null;
}
- private DateInterval toYearIsoInterval( DateUnit dateUnit, int offset, int length )
+ private DateInterval toYearIsoInterval( DateTimeUnit dateTimeUnit, int offset, int length )
{
- DateTime from = dateUnit.toDateTime( chronology );
+ DateTime from = dateTimeUnit.toJodaDateTime( chronology );
if ( offset > 0 )
{
@@ -105,18 +105,18 @@
DateTime to = new DateTime( from ).plusYears( length ).minusDays( 1 );
- DateUnit fromDateUnit = DateUnit.fromDateTime( from );
- DateUnit toDateUnit = DateUnit.fromDateTime( to );
-
- fromDateUnit.setDayOfWeek( isoWeekday( fromDateUnit ) );
- toDateUnit.setDayOfWeek( isoWeekday( toDateUnit ) );
-
- return new DateInterval( toIso( fromDateUnit ), toIso( toDateUnit ), DateIntervalType.ISO8601_YEAR );
+ DateTimeUnit fromDateTimeUnit = DateTimeUnit.fromJodaDateTime( from );
+ DateTimeUnit toDateTimeUnit = DateTimeUnit.fromJodaDateTime( to );
+
+ fromDateTimeUnit.setDayOfWeek( isoWeekday( fromDateTimeUnit ) );
+ toDateTimeUnit.setDayOfWeek( isoWeekday( toDateTimeUnit ) );
+
+ return new DateInterval( toIso( fromDateTimeUnit ), toIso( toDateTimeUnit ), DateIntervalType.ISO8601_YEAR );
}
- private DateInterval toMonthIsoInterval( DateUnit dateUnit, int offset, int length )
+ private DateInterval toMonthIsoInterval( DateTimeUnit dateTimeUnit, int offset, int length )
{
- DateTime from = dateUnit.toDateTime( chronology );
+ DateTime from = dateTimeUnit.toJodaDateTime( chronology );
if ( offset > 0 )
{
@@ -129,18 +129,18 @@
DateTime to = new DateTime( from ).plusMonths( length ).minusDays( 1 );
- DateUnit fromDateUnit = DateUnit.fromDateTime( from );
- DateUnit toDateUnit = DateUnit.fromDateTime( to );
-
- fromDateUnit.setDayOfWeek( isoWeekday( fromDateUnit ) );
- toDateUnit.setDayOfWeek( isoWeekday( toDateUnit ) );
-
- return new DateInterval( toIso( fromDateUnit ), toIso( toDateUnit ), DateIntervalType.ISO8601_MONTH );
+ DateTimeUnit fromDateTimeUnit = DateTimeUnit.fromJodaDateTime( from );
+ DateTimeUnit toDateTimeUnit = DateTimeUnit.fromJodaDateTime( to );
+
+ fromDateTimeUnit.setDayOfWeek( isoWeekday( fromDateTimeUnit ) );
+ toDateTimeUnit.setDayOfWeek( isoWeekday( toDateTimeUnit ) );
+
+ return new DateInterval( toIso( fromDateTimeUnit ), toIso( toDateTimeUnit ), DateIntervalType.ISO8601_MONTH );
}
- private DateInterval toWeekIsoInterval( DateUnit dateUnit, int offset, int length )
+ private DateInterval toWeekIsoInterval( DateTimeUnit dateTimeUnit, int offset, int length )
{
- DateTime from = dateUnit.toDateTime( chronology );
+ DateTime from = dateTimeUnit.toJodaDateTime( chronology );
if ( offset > 0 )
{
@@ -153,18 +153,18 @@
DateTime to = new DateTime( from ).plusWeeks( length ).minusDays( 1 );
- DateUnit fromDateUnit = DateUnit.fromDateTime( from );
- DateUnit toDateUnit = DateUnit.fromDateTime( to );
-
- fromDateUnit.setDayOfWeek( isoWeekday( fromDateUnit ) );
- toDateUnit.setDayOfWeek( isoWeekday( toDateUnit ) );
-
- return new DateInterval( toIso( fromDateUnit ), toIso( toDateUnit ), DateIntervalType.ISO8601_WEEK );
+ DateTimeUnit fromDateTimeUnit = DateTimeUnit.fromJodaDateTime( from );
+ DateTimeUnit toDateTimeUnit = DateTimeUnit.fromJodaDateTime( to );
+
+ fromDateTimeUnit.setDayOfWeek( isoWeekday( fromDateTimeUnit ) );
+ toDateTimeUnit.setDayOfWeek( isoWeekday( toDateTimeUnit ) );
+
+ return new DateInterval( toIso( fromDateTimeUnit ), toIso( toDateTimeUnit ), DateIntervalType.ISO8601_WEEK );
}
- private DateInterval toDayIsoInterval( DateUnit dateUnit, int offset, int length )
+ private DateInterval toDayIsoInterval( DateTimeUnit dateTimeUnit, int offset, int length )
{
- DateTime from = dateUnit.toDateTime( chronology );
+ DateTime from = dateTimeUnit.toJodaDateTime( chronology );
if ( offset > 0 )
{
@@ -177,13 +177,13 @@
DateTime to = new DateTime( from ).plusDays( length );
- DateUnit fromDateUnit = DateUnit.fromDateTime( from );
- DateUnit toDateUnit = DateUnit.fromDateTime( to );
-
- fromDateUnit.setDayOfWeek( isoWeekday( fromDateUnit ) );
- toDateUnit.setDayOfWeek( isoWeekday( toDateUnit ) );
-
- return new DateInterval( toIso( fromDateUnit ), toIso( toDateUnit ), DateIntervalType.ISO8601_DAY );
+ DateTimeUnit fromDateTimeUnit = DateTimeUnit.fromJodaDateTime( from );
+ DateTimeUnit toDateTimeUnit = DateTimeUnit.fromJodaDateTime( to );
+
+ fromDateTimeUnit.setDayOfWeek( isoWeekday( fromDateTimeUnit ) );
+ toDateTimeUnit.setDayOfWeek( isoWeekday( toDateTimeUnit ) );
+
+ return new DateInterval( toIso( fromDateTimeUnit ), toIso( toDateTimeUnit ), DateIntervalType.ISO8601_DAY );
}
@Override
@@ -222,86 +222,86 @@
}
@Override
- public int isoWeek( DateUnit dateUnit )
+ public int isoWeek( DateTimeUnit dateTimeUnit )
{
- DateTime dateTime = dateUnit.toDateTime( chronology );
+ DateTime dateTime = dateTimeUnit.toJodaDateTime( chronology );
return dateTime.getWeekOfWeekyear();
}
@Override
- public int week( DateUnit dateUnit )
+ public int week( DateTimeUnit dateTimeUnit )
{
- return isoWeek( dateUnit );
+ return isoWeek( dateTimeUnit );
}
@Override
- public int isoWeekday( DateUnit dateUnit )
+ public int isoWeekday( DateTimeUnit dateTimeUnit )
{
- DateTime dateTime = dateUnit.toDateTime( chronology );
+ DateTime dateTime = dateTimeUnit.toJodaDateTime( chronology );
dateTime = dateTime.withChronology( ISOChronology.getInstance() );
return dateTime.getDayOfWeek();
}
@Override
- public int weekday( DateUnit dateUnit )
+ public int weekday( DateTimeUnit dateTimeUnit )
{
- DateTime dateTime = dateUnit.toDateTime( chronology );
+ DateTime dateTime = dateTimeUnit.toJodaDateTime( chronology );
return dateTime.getDayOfWeek();
}
@Override
- public DateUnit plusDays( DateUnit dateUnit, int days )
- {
- DateTime dateTime = dateUnit.toDateTime( chronology );
- return DateUnit.fromDateTime( dateTime.plusDays( days ) );
- }
-
- @Override
- public DateUnit minusDays( DateUnit dateUnit, int days )
- {
- DateTime dateTime = dateUnit.toDateTime( chronology );
- return DateUnit.fromDateTime( dateTime.minusDays( days ) );
- }
-
- @Override
- public DateUnit plusWeeks( DateUnit dateUnit, int weeks )
- {
- DateTime dateTime = dateUnit.toDateTime( chronology );
- return DateUnit.fromDateTime( dateTime.plusWeeks( weeks ) );
- }
-
- @Override
- public DateUnit minusWeeks( DateUnit dateUnit, int weeks )
- {
- DateTime dateTime = dateUnit.toDateTime( chronology );
- return DateUnit.fromDateTime( dateTime.minusWeeks( weeks ) );
- }
-
- @Override
- public DateUnit plusMonths( DateUnit dateUnit, int months )
- {
- DateTime dateTime = dateUnit.toDateTime( chronology );
- return DateUnit.fromDateTime( dateTime.plusMonths( months ) );
- }
-
- @Override
- public DateUnit minusMonths( DateUnit dateUnit, int months )
- {
- DateTime dateTime = dateUnit.toDateTime( chronology );
- return DateUnit.fromDateTime( dateTime.minusMonths( months ) );
- }
-
- @Override
- public DateUnit plusYears( DateUnit dateUnit, int years )
- {
- DateTime dateTime = dateUnit.toDateTime( chronology );
- return DateUnit.fromDateTime( dateTime.plusYears( years ) );
- }
-
- @Override
- public DateUnit minusYears( DateUnit dateUnit, int years )
- {
- DateTime dateTime = dateUnit.toDateTime( chronology );
- return DateUnit.fromDateTime( dateTime.minusYears( years ) );
+ public DateTimeUnit plusDays( DateTimeUnit dateTimeUnit, int days )
+ {
+ DateTime dateTime = dateTimeUnit.toJodaDateTime( chronology );
+ return DateTimeUnit.fromJodaDateTime( dateTime.plusDays( days ) );
+ }
+
+ @Override
+ public DateTimeUnit minusDays( DateTimeUnit dateTimeUnit, int days )
+ {
+ DateTime dateTime = dateTimeUnit.toJodaDateTime( chronology );
+ return DateTimeUnit.fromJodaDateTime( dateTime.minusDays( days ) );
+ }
+
+ @Override
+ public DateTimeUnit plusWeeks( DateTimeUnit dateTimeUnit, int weeks )
+ {
+ DateTime dateTime = dateTimeUnit.toJodaDateTime( chronology );
+ return DateTimeUnit.fromJodaDateTime( dateTime.plusWeeks( weeks ) );
+ }
+
+ @Override
+ public DateTimeUnit minusWeeks( DateTimeUnit dateTimeUnit, int weeks )
+ {
+ DateTime dateTime = dateTimeUnit.toJodaDateTime( chronology );
+ return DateTimeUnit.fromJodaDateTime( dateTime.minusWeeks( weeks ) );
+ }
+
+ @Override
+ public DateTimeUnit plusMonths( DateTimeUnit dateTimeUnit, int months )
+ {
+ DateTime dateTime = dateTimeUnit.toJodaDateTime( chronology );
+ return DateTimeUnit.fromJodaDateTime( dateTime.plusMonths( months ) );
+ }
+
+ @Override
+ public DateTimeUnit minusMonths( DateTimeUnit dateTimeUnit, int months )
+ {
+ DateTime dateTime = dateTimeUnit.toJodaDateTime( chronology );
+ return DateTimeUnit.fromJodaDateTime( dateTime.minusMonths( months ) );
+ }
+
+ @Override
+ public DateTimeUnit plusYears( DateTimeUnit dateTimeUnit, int years )
+ {
+ DateTime dateTime = dateTimeUnit.toJodaDateTime( chronology );
+ return DateTimeUnit.fromJodaDateTime( dateTime.plusYears( years ) );
+ }
+
+ @Override
+ public DateTimeUnit minusYears( DateTimeUnit dateTimeUnit, int years )
+ {
+ DateTime dateTime = dateTimeUnit.toJodaDateTime( chronology );
+ return DateTimeUnit.fromJodaDateTime( dateTime.minusYears( years ) );
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateInterval.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateInterval.java 2014-05-20 08:02:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateInterval.java 2014-08-29 10:02:21 +0000
@@ -33,7 +33,7 @@
/**
* Class representing a date interval.
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- * @see DateUnit
+ * @see DateTimeUnit
* @see Calendar
*/
public class DateInterval
@@ -42,38 +42,38 @@
* Start of interval. Required.
*/
@NotNull
- private final DateUnit from;
+ private final DateTimeUnit from;
/**
* End of interval. Required.
*/
@NotNull
- private final DateUnit to;
+ private final DateTimeUnit to;
/**
* Interval type this interval represents.
*/
private DateIntervalType type;
- public DateInterval( DateUnit from, DateUnit to )
+ public DateInterval( DateTimeUnit from, DateTimeUnit to )
{
this.from = from;
this.to = to;
}
- public DateInterval( DateUnit from, DateUnit to, DateIntervalType type )
+ public DateInterval( DateTimeUnit from, DateTimeUnit to, DateIntervalType type )
{
this.from = from;
this.to = to;
this.type = type;
}
- public DateUnit getFrom()
+ public DateTimeUnit getFrom()
{
return from;
}
- public DateUnit getTo()
+ public DateTimeUnit getTo()
{
return to;
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateTimeUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateTimeUnit.java 2014-05-21 13:20:31 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateTimeUnit.java 2014-08-29 10:02:21 +0000
@@ -28,77 +28,310 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.joda.time.Chronology;
import org.joda.time.DateTime;
+import org.joda.time.chrono.ISOChronology;
+import javax.validation.constraints.NotNull;
import java.util.Date;
+import java.util.GregorianCalendar;
/**
- * Simple class that can hold both a TimeUnit and DateUnit which is useful in cases
- * where we are converting from a DateTime, Jdk Calendar or Jdk Date and don't want to
- * loose either date or time dimension.
+ * Class representing a specific calendar date.
*
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- * @see DateUnit
- * @see TimeUnit
- * @see org.joda.time.DateTime
- * @see java.util.Calendar
- * @see java.util.Date
+ * @see DateInterval
+ * @see Calendar
*/
public class DateTimeUnit
{
- private DateUnit dateUnit;
-
- private TimeUnit timeUnit;
+ /**
+ * Year of date. Required.
+ */
+ @NotNull
+ private int year;
+
+ /**
+ * Month of date. Required.
+ */
+ @NotNull
+ private int month;
+
+ /**
+ * Day of date. Required.
+ */
+ @NotNull
+ private int day;
+
+ /**
+ * Day of week, numbering is unspecified and left up to user.
+ */
+ private int dayOfWeek;
+
+ /**
+ * Does dateUnit represent ISO 8601.
+ */
+ final boolean iso8601;
+
+ /**
+ * Hour of day, range is 1 - 24.
+ */
+ private int hour;
+
+ /**
+ * Minute of hour, range is 0 - 59.
+ */
+ private int minute;
+
+ /**
+ * Second of minute, range is 0 - 59.
+ */
+ private int second;
+
+ /**
+ * Millisecond of second, range is 0 - 999.
+ */
+ private int millis;
+
+ public DateTimeUnit( boolean iso8601 )
+ {
+ this.iso8601 = iso8601;
+ this.hour = 0;
+ this.minute = 0;
+ this.second = 0;
+ this.millis = 0;
+ }
public DateTimeUnit()
{
- }
-
- public DateTimeUnit( DateUnit dateUnit, TimeUnit timeUnit )
- {
- this.dateUnit = dateUnit;
- this.timeUnit = timeUnit;
- }
-
- public DateUnit getDateUnit()
- {
- return dateUnit;
- }
-
- public void setDateUnit( DateUnit dateUnit )
- {
- this.dateUnit = dateUnit;
- }
-
- public TimeUnit getTimeUnit()
- {
- return timeUnit;
- }
-
- public void setTimeUnit( TimeUnit timeUnit )
- {
- this.timeUnit = timeUnit;
- }
-
- public static DateTimeUnit fromDateTime( DateTime dateTime )
- {
- DateUnit dateUnit = DateUnit.fromDateTime( dateTime );
- TimeUnit timeUnit = TimeUnit.fromDateTime( dateTime );
-
- return new DateTimeUnit( dateUnit, timeUnit );
- }
-
+ this( false );
+ }
+
+ public DateTimeUnit( DateTimeUnit dateTimeUnit )
+ {
+ this( dateTimeUnit.isIso8601() );
+ this.year = dateTimeUnit.getYear();
+ this.month = dateTimeUnit.getMonth();
+ this.day = dateTimeUnit.getDay();
+ this.dayOfWeek = dateTimeUnit.getDayOfWeek();
+ }
+
+ public DateTimeUnit( DateTimeUnit dateTimeUnit, boolean iso8601 )
+ {
+ this( iso8601 );
+ this.year = dateTimeUnit.getYear();
+ this.month = dateTimeUnit.getMonth();
+ this.day = dateTimeUnit.getDay();
+ this.dayOfWeek = dateTimeUnit.getDayOfWeek();
+ }
+
+ public DateTimeUnit( int year, int month, int day, boolean iso8601 )
+ {
+ this( iso8601 );
+ this.year = year;
+ this.month = month;
+ this.day = day;
+ }
+
+ public DateTimeUnit( int year, int month, int day )
+ {
+ this( year, month, day, false );
+ }
+
+ public DateTimeUnit( int year, int month, int day, int dayOfWeek, boolean iso8601 )
+ {
+ this( year, month, day, iso8601 );
+ this.dayOfWeek = dayOfWeek;
+ }
+
+ public DateTimeUnit( int year, int month, int day, int dayOfWeek )
+ {
+ this( year, month, day, dayOfWeek, false );
+ }
+
+ public int getYear()
+ {
+ return year;
+ }
+
+ public void setYear( int year )
+ {
+ this.year = year;
+ }
+
+ public int getMonth()
+ {
+ return month;
+ }
+
+ public void setMonth( int month )
+ {
+ this.month = month;
+ }
+
+ public int getDay()
+ {
+ return day;
+ }
+
+ public void setDay( int day )
+ {
+ this.day = day;
+ }
+
+ public int getDayOfWeek()
+ {
+ return dayOfWeek;
+ }
+
+ public void setDayOfWeek( int dayOfWeek )
+ {
+ this.dayOfWeek = dayOfWeek;
+ }
+
+ public boolean isIso8601()
+ {
+ return iso8601;
+ }
+
+ public int getHour()
+ {
+ return hour;
+ }
+
+ public void setHour( int hour )
+ {
+ this.hour = hour;
+ }
+
+ public int getMinute()
+ {
+ return minute;
+ }
+
+ public void setMinute( int minute )
+ {
+ this.minute = minute;
+ }
+
+ public int getSecond()
+ {
+ return second;
+ }
+
+ public void setSecond( int second )
+ {
+ this.second = second;
+ }
+
+ public int getMillis()
+ {
+ return millis;
+ }
+
+ public void setMillis( int millis )
+ {
+ this.millis = millis;
+ }
+
+ /**
+ * Converts dateUnit to Joda-Time DateTime
+ *
+ * @return Populated DateTime object
+ */
+ public DateTime toDateTime()
+ {
+ if ( !iso8601 )
+ {
+ throw new RuntimeException( "Cannot convert non-ISO8601 DateUnit to DateTime." );
+ }
+
+ return new DateTime( year, month, day, 12, 0, ISOChronology.getInstance() );
+ }
+
+ /**
+ * Converts dateUnit to Joda-Time DateTime with a specific chronology.
+ *
+ * @param chronology Chronology to use
+ * @return Populated DateTime object
+ */
+ public DateTime toJodaDateTime( Chronology chronology )
+ {
+ return new DateTime( year, month, day, 12, 0, chronology );
+ }
+
+ /**
+ * Converts dateUnit to JDK Calendar
+ *
+ * @return Populated JDK Calendar object
+ */
+ public java.util.Calendar toJdkCalendar()
+ {
+ if ( !iso8601 )
+ {
+ throw new RuntimeException( "Cannot convert non-ISO8601 DateUnit to JDK Calendar." );
+ }
+
+ java.util.Calendar calendar = new GregorianCalendar( year, month - 1, day );
+ calendar.setTime( calendar.getTime() );
+
+ return calendar;
+ }
+
+ /**
+ * Converts dateUnit to JDK Date
+ *
+ * @return Populated JDK Date object
+ */
+ public Date toJdkDate()
+ {
+ return toJdkCalendar().getTime();
+ }
+
+ /**
+ * Converts from Joda-Time DateTime to DateUnit
+ *
+ * @param dateTime DateTime object
+ * @return Populated DateUnit object
+ */
+ public static DateTimeUnit fromJodaDateTime( DateTime dateTime )
+ {
+ return new DateTimeUnit( dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), dateTime.getDayOfWeek() );
+ }
+
+ /**
+ * Converts from Joda-Time DateTime to DateUnit
+ *
+ * @param dateTime DateTime object
+ * @param iso8601 whether date time is iso8601
+ * @return Populated DateUnit object
+ */
+ public static DateTimeUnit fromJodaDateTime( DateTime dateTime, boolean iso8601 )
+ {
+ return new DateTimeUnit( dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), dateTime.getDayOfWeek(), iso8601 );
+ }
+
+ /**
+ * Converts from JDK Calendar to DateUnit
+ *
+ * @param calendar JDK Calendar object
+ * @return Populated DateUnit object
+ */
public static DateTimeUnit fromJdkCalendar( java.util.Calendar calendar )
{
- DateUnit dateUnit = DateUnit.fromJdkCalendar( calendar );
- TimeUnit timeUnit = TimeUnit.fromJdkCalendar( calendar );
-
- return new DateTimeUnit( dateUnit, timeUnit );
+ return new DateTimeUnit( calendar.get( java.util.Calendar.YEAR ), calendar.get( java.util.Calendar.MONTH ) + 1,
+ calendar.get( java.util.Calendar.DAY_OF_MONTH ), calendar.get( java.util.Calendar.DAY_OF_WEEK ), true );
}
+ /**
+ * Converts from JDK Date to DateUnit
+ *
+ * @param date JDK Date object
+ * @return Populated DateUnit object
+ */
public static DateTimeUnit fromJdkDate( Date date )
{
- return fromDateTime( new DateTime( date.getTime() ) );
+ return fromJodaDateTime( new DateTime( date.getTime() ), true );
}
@Override
@@ -107,10 +340,12 @@
if ( this == o ) return true;
if ( o == null || getClass() != o.getClass() ) return false;
- DateTimeUnit that = (DateTimeUnit) o;
+ DateTimeUnit dateTimeUnit = (DateTimeUnit) o;
- if ( dateUnit != null ? !dateUnit.equals( that.dateUnit ) : that.dateUnit != null ) return false;
- if ( timeUnit != null ? !timeUnit.equals( that.timeUnit ) : that.timeUnit != null ) return false;
+ if ( day != dateTimeUnit.day ) return false;
+ if ( iso8601 != dateTimeUnit.iso8601 ) return false;
+ if ( month != dateTimeUnit.month ) return false;
+ if ( year != dateTimeUnit.year ) return false;
return true;
}
@@ -118,17 +353,21 @@
@Override
public int hashCode()
{
- int result = dateUnit != null ? dateUnit.hashCode() : 0;
- result = 31 * result + (timeUnit != null ? timeUnit.hashCode() : 0);
+ int result = year;
+ result = 31 * result + month;
+ result = 31 * result + day;
+ result = 31 * result + (iso8601 ? 1 : 0);
return result;
}
@Override
public String toString()
{
- return "DateTimeUnit{" +
- "dateUnit=" + dateUnit +
- ", timeUnit=" + timeUnit +
+ return "DateUnit{" +
+ "year=" + year +
+ ", month=" + month +
+ ", day=" + day +
+ ", iso8601=" + iso8601 +
'}';
}
}
=== removed 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-08-28 13:10:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateUnit.java 1970-01-01 00:00:00 +0000
@@ -1,311 +0,0 @@
-package org.hisp.dhis.calendar;
-
-/*
- * Copyright (c) 2004-2014, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.joda.time.Chronology;
-import org.joda.time.DateTime;
-import org.joda.time.chrono.ISOChronology;
-
-import javax.validation.constraints.NotNull;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-/**
- * Class representing a specific calendar date.
- *
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- * @see DateInterval
- * @see Calendar
- * @see TimeUnit
- * @see DateTimeUnit
- */
-public class DateUnit
-{
- /**
- * Year of date. Required.
- */
- @NotNull
- int year;
-
- /**
- * Month of date. Required.
- */
- @NotNull
- int month;
-
- /**
- * Day of date. Required.
- */
- @NotNull
- int day;
-
- /**
- * Day of week, numbering is unspecified and left up to user.
- */
- int dayOfWeek;
-
- /**
- * Does dateUnit represent ISO 8601.
- */
- final boolean iso8601;
-
- public DateUnit( boolean iso8601 )
- {
- this.iso8601 = iso8601;
- }
-
- public DateUnit()
- {
- this( false );
- }
-
- public DateUnit( DateUnit dateUnit )
- {
- this( dateUnit.isIso8601() );
- this.year = dateUnit.getYear();
- this.month = dateUnit.getMonth();
- this.day = dateUnit.getDay();
- this.dayOfWeek = dateUnit.getDayOfWeek();
- }
-
- public DateUnit( DateUnit dateUnit, boolean iso8601 )
- {
- this( iso8601 );
- this.year = dateUnit.getYear();
- this.month = dateUnit.getMonth();
- this.day = dateUnit.getDay();
- this.dayOfWeek = dateUnit.getDayOfWeek();
- }
-
- public DateUnit( int year, int month, int day, boolean iso8601 )
- {
- this.year = year;
- this.month = month;
- this.day = day;
- this.iso8601 = iso8601;
- }
-
- public DateUnit( int year, int month, int day )
- {
- this( year, month, day, false );
- }
-
- public DateUnit( int year, int month, int day, int dayOfWeek, boolean iso8601 )
- {
- this( year, month, day, iso8601 );
- this.dayOfWeek = dayOfWeek;
- }
-
- public DateUnit( int year, int month, int day, int dayOfWeek )
- {
- this( year, month, day, dayOfWeek, false );
- }
-
- public int getYear()
- {
- return year;
- }
-
- public void setYear( int year )
- {
- this.year = year;
- }
-
- public int getMonth()
- {
- return month;
- }
-
- public void setMonth( int month )
- {
- this.month = month;
- }
-
- public int getDay()
- {
- return day;
- }
-
- public void setDay( int day )
- {
- this.day = day;
- }
-
- public int getDayOfWeek()
- {
- return dayOfWeek;
- }
-
- public void setDayOfWeek( int dayOfWeek )
- {
- this.dayOfWeek = dayOfWeek;
- }
-
- public boolean isIso8601()
- {
- return iso8601;
- }
-
- /**
- * Converts dateUnit to Joda-Time DateTime
- *
- * @return Populated DateTime object
- */
- public DateTime toDateTime()
- {
- if ( !iso8601 )
- {
- throw new RuntimeException( "Cannot convert non-ISO8601 DateUnit to DateTime." );
- }
-
- return new DateTime( year, month, day, 12, 0, ISOChronology.getInstance() );
- }
-
- /**
- * Converts dateUnit to Joda-Time DateTime with a specific chronology.
- *
- * @param chronology Chronology to use
- * @return Populated DateTime object
- */
- public DateTime toDateTime( Chronology chronology )
- {
- return new DateTime( year, month, day, 12, 0, chronology );
- }
-
- /**
- * Converts dateUnit to JDK Calendar
- *
- * @return Populated JDK Calendar object
- */
- public java.util.Calendar toJdkCalendar()
- {
- if ( !iso8601 )
- {
- throw new RuntimeException( "Cannot convert non-ISO8601 DateUnit to JDK Calendar." );
- }
-
- java.util.Calendar calendar = new GregorianCalendar( year, month - 1, day );
- calendar.setTime( calendar.getTime() );
-
- return calendar;
- }
-
- /**
- * Converts dateUnit to JDK Date
- *
- * @return Populated JDK Date object
- */
- public Date toJdkDate()
- {
- return toJdkCalendar().getTime();
- }
-
- /**
- * Converts from Joda-Time DateTime to DateUnit
- *
- * @param dateTime DateTime object
- * @return Populated DateUnit object
- */
- public static DateUnit fromDateTime( DateTime dateTime )
- {
- return new DateUnit( dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), dateTime.getDayOfWeek() );
- }
-
- /**
- * Converts from Joda-Time DateTime to DateUnit
- *
- * @param dateTime DateTime object
- * @param iso8601 whether date time is iso8601
- * @return Populated DateUnit object
- */
- public static DateUnit fromDateTime( DateTime dateTime, boolean iso8601 )
- {
- return new DateUnit( dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), dateTime.getDayOfWeek(), iso8601 );
- }
-
- /**
- * Converts from JDK Calendar to DateUnit
- *
- * @param calendar JDK Calendar object
- * @return Populated DateUnit object
- */
- public static DateUnit fromJdkCalendar( java.util.Calendar calendar )
- {
- return new DateUnit( calendar.get( java.util.Calendar.YEAR ), calendar.get( java.util.Calendar.MONTH ) + 1,
- calendar.get( java.util.Calendar.DAY_OF_MONTH ), calendar.get( java.util.Calendar.DAY_OF_WEEK ), true );
- }
-
- /**
- * Converts from JDK Date to DateUnit
- *
- * @param date JDK Date object
- * @return Populated DateUnit object
- */
- public static DateUnit fromJdkDate( Date date )
- {
- return fromDateTime( new DateTime( date.getTime() ), true );
- }
-
- @Override
- public boolean equals( Object o )
- {
- if ( this == o ) return true;
- if ( o == null || getClass() != o.getClass() ) return false;
-
- DateUnit dateUnit = (DateUnit) o;
-
- if ( day != dateUnit.day ) return false;
- if ( iso8601 != dateUnit.iso8601 ) return false;
- if ( month != dateUnit.month ) return false;
- if ( year != dateUnit.year ) return false;
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result = year;
- result = 31 * result + month;
- result = 31 * result + day;
- result = 31 * result + (iso8601 ? 1 : 0);
- return result;
- }
-
- @Override
- public String toString()
- {
- return "DateUnit{" +
- "year=" + year +
- ", month=" + month +
- ", day=" + day +
- ", iso8601=" + iso8601 +
- '}';
- }
-}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateUnitPeriodTypeParser.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateUnitPeriodTypeParser.java 2014-08-14 05:46:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateUnitPeriodTypeParser.java 2014-08-29 10:02:21 +0000
@@ -105,10 +105,10 @@
int month = Integer.parseInt( matcher.group( 2 ) );
int day = Integer.parseInt( matcher.group( 3 ) );
- DateUnit dateUnit = new DateUnit( year, month, day );
- dateUnit.setDayOfWeek(calendar.weekday(dateUnit));
+ DateTimeUnit dateTimeUnit = new DateTimeUnit( year, month, day );
+ dateTimeUnit.setDayOfWeek(calendar.weekday( dateTimeUnit ));
- return new DateInterval( dateUnit, dateUnit );
+ return new DateInterval( dateTimeUnit, dateTimeUnit );
}
else if ( DateUnitType.WEEKLY.equals( type ) )
{
@@ -120,7 +120,7 @@
return null;
}
- DateUnit start = new DateUnit( year, 1, 1 );
+ DateTimeUnit start = new DateTimeUnit( year, 1, 1 );
start = calendar.minusDays(start, calendar.weekday(start) - 1); // rewind to start of week
// since we rewind to start of week, we might end up in the previous years weeks, so we check and forward if needed
@@ -130,7 +130,7 @@
}
start = calendar.plusWeeks(start, week - 1);
- DateUnit end = new DateUnit( start );
+ DateTimeUnit end = new DateTimeUnit( start );
end = calendar.plusWeeks(end, 1);
end = calendar.minusDays(end, 1);
@@ -144,8 +144,8 @@
int year = Integer.parseInt( matcher.group( 1 ) );
int month = Integer.parseInt( matcher.group( 2 ) );
- DateUnit start = new DateUnit( year, month, 1 );
- DateUnit end = new DateUnit( year, month, calendar.daysInMonth(start.getYear(), start.getMonth()) );
+ DateTimeUnit start = new DateTimeUnit( year, month, 1 );
+ DateTimeUnit end = new DateTimeUnit( year, month, calendar.daysInMonth(start.getYear(), start.getMonth()) );
start.setDayOfWeek( calendar.weekday(start) );
end.setDayOfWeek(calendar.weekday(end));
@@ -162,8 +162,8 @@
return null;
}
- DateUnit start = new DateUnit( year, (month * 2) - 1, 1 );
- DateUnit end = new DateUnit( start );
+ DateTimeUnit start = new DateTimeUnit( year, (month * 2) - 1, 1 );
+ DateTimeUnit end = new DateTimeUnit( start );
end = calendar.plusMonths(end, 2);
end = calendar.minusDays(end, 1);
@@ -183,8 +183,8 @@
return null;
}
- DateUnit start = new DateUnit( year, ((quarter - 1) * 3) + 1, 1 );
- DateUnit end = new DateUnit( start );
+ DateTimeUnit start = new DateTimeUnit( year, ((quarter - 1) * 3) + 1, 1 );
+ DateTimeUnit end = new DateTimeUnit( start );
end = calendar.plusMonths(end, 3);
end = calendar.minusDays(end, 1);
@@ -204,8 +204,8 @@
return null;
}
- DateUnit start = new DateUnit( year, semester == 1 ? 1 : 7, 1 );
- DateUnit end = new DateUnit( start );
+ DateTimeUnit start = new DateTimeUnit( year, semester == 1 ? 1 : 7, 1 );
+ DateTimeUnit end = new DateTimeUnit( start );
end = calendar.plusMonths(end, 6);
end = calendar.minusDays(end, 1);
@@ -225,8 +225,8 @@
return null;
}
- DateUnit start = new DateUnit( year, semester == 1 ? 4 : 10, 1 );
- DateUnit end = new DateUnit( start );
+ DateTimeUnit start = new DateTimeUnit( year, semester == 1 ? 4 : 10, 1 );
+ DateTimeUnit end = new DateTimeUnit( start );
end = calendar.plusMonths(end, 6);
end = calendar.minusDays(end, 1);
@@ -239,8 +239,8 @@
{
int year = Integer.parseInt( matcher.group( 1 ) );
- DateUnit start = new DateUnit( year, 1, 1 );
- DateUnit end = new DateUnit( year, calendar.monthsInYear(),
+ DateTimeUnit start = new DateTimeUnit( year, 1, 1 );
+ DateTimeUnit end = new DateTimeUnit( year, calendar.monthsInYear(),
calendar.daysInMonth(start.getYear(), calendar.monthsInYear()) );
start.setDayOfWeek(calendar.weekday(start));
@@ -252,8 +252,8 @@
{
int year = Integer.parseInt( matcher.group( 1 ) );
- DateUnit start = new DateUnit( year, 4, 1 );
- DateUnit end = new DateUnit( start );
+ DateTimeUnit start = new DateTimeUnit( year, 4, 1 );
+ DateTimeUnit end = new DateTimeUnit( start );
end = calendar.plusYears(end, 1);
end = calendar.minusDays(end, 1);
@@ -266,8 +266,8 @@
{
int year = Integer.parseInt( matcher.group( 1 ) );
- DateUnit start = new DateUnit( year, 7, 1 );
- DateUnit end = new DateUnit( start );
+ DateTimeUnit start = new DateTimeUnit( year, 7, 1 );
+ DateTimeUnit end = new DateTimeUnit( start );
end = calendar.plusYears(end, 1);
end = calendar.minusDays(end, 1);
@@ -280,8 +280,8 @@
{
int year = Integer.parseInt( matcher.group( 1 ) );
- DateUnit start = new DateUnit( year, 10, 1 );
- DateUnit end = new DateUnit( start );
+ DateTimeUnit start = new DateTimeUnit( year, 10, 1 );
+ DateTimeUnit end = new DateTimeUnit( start );
end = calendar.plusYears(end, 1);
end = calendar.minusDays(end, 1);
=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/TimeUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/TimeUnit.java 2014-08-26 08:03:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/TimeUnit.java 1970-01-01 00:00:00 +0000
@@ -1,172 +0,0 @@
-package org.hisp.dhis.calendar;
-
-/*
- * Copyright (c) 2004-2014, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.joda.time.DateTime;
-
-import java.util.Calendar;
-import java.util.Date;
-
-/**
- * Simple class to hold information about time, can be used together with DateUnit to form
- * a DateTimeUnit which holds both date and time information. Useful in cases where converting
- * from a JDK Date/Calendar and you don't want to loose the time dimension.
- *
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- * @see DateUnit
- * @see DateTimeUnit
- */
-public class TimeUnit
-{
- /**
- * Hour of day, range is 1 - 24.
- */
- private int hour;
-
- /**
- * Minute of day, range is 0 - 59.
- */
- private int minute;
-
- /**
- * Second of day, range is 0 - 59.
- */
- private int second;
-
- public TimeUnit()
- {
- }
-
- public TimeUnit( int hour, int minute, int second )
- {
- this.hour = hour;
- this.minute = minute;
- this.second = second;
- }
-
- public int getHour()
- {
- return hour;
- }
-
- public void setHour( int hour )
- {
- this.hour = hour;
- }
-
- public int getMinute()
- {
- return minute;
- }
-
- public void setMinute( int minute )
- {
- this.minute = minute;
- }
-
- public int getSecond()
- {
- return second;
- }
-
- public void setSecond( int second )
- {
- this.second = second;
- }
-
- /**
- * Convert a Joda-Time DateTime object to a TimeUnit
- *
- * @param dateTime DateTime object to convert
- * @return TimeUnit object created from given DateTime
- */
- public static TimeUnit fromDateTime( DateTime dateTime )
- {
- return new TimeUnit( dateTime.getHourOfDay(), dateTime.getMinuteOfHour(), dateTime.getSecondOfMinute() );
- }
-
- /**
- * Convert a JDK Calendar to TimeUnit object
- *
- * @param calendar Calendar to convert
- * @return TimeUnit object created from given Calendar
- */
- public static TimeUnit fromJdkCalendar( Calendar calendar )
- {
- int amPm = calendar.get( Calendar.AM_PM );
-
- return new TimeUnit( calendar.get( Calendar.HOUR ) + (amPm * 12), calendar.get( Calendar.MINUTE ),
- calendar.get( Calendar.SECOND ) );
- }
-
- /**
- * Convert a JDK Date to TimeUnit object
- *
- * @param date Date to convert
- * @return TimeUnit object created from given Date
- */
- public static TimeUnit fromJdkDate( Date date )
- {
- return fromDateTime( new DateTime( date.getTime() ) );
- }
-
- @Override
- public boolean equals( Object o )
- {
- if ( this == o ) return true;
- if ( o == null || getClass() != o.getClass() ) return false;
-
- TimeUnit timeUnit = (TimeUnit) o;
-
- if ( hour != timeUnit.hour ) return false;
- if ( minute != timeUnit.minute ) return false;
- if ( second != timeUnit.second ) return false;
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result = hour;
- result = 31 * result + minute;
- result = 31 * result + second;
- return result;
- }
-
- @Override
- public String toString()
- {
- return "TimeUnit{" +
- "hour=" + hour +
- ", minute=" + minute +
- ", second=" + second +
- '}';
- }
-}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/NepaliCalendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/NepaliCalendar.java 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/NepaliCalendar.java 2014-08-29 10:02:21 +0000
@@ -32,7 +32,7 @@
import org.hisp.dhis.calendar.Calendar;
import org.hisp.dhis.calendar.DateInterval;
import org.hisp.dhis.calendar.DateIntervalType;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import org.joda.time.DateTime;
import org.joda.time.Days;
import org.joda.time.chrono.ISOChronology;
@@ -47,9 +47,9 @@
@Component
public class NepaliCalendar extends AbstractCalendar
{
- private static final DateUnit startNepal = new DateUnit( 2000, 1, 1, java.util.Calendar.WEDNESDAY );
+ private static final DateTimeUnit startNepal = new DateTimeUnit( 2000, 1, 1, java.util.Calendar.WEDNESDAY );
- private static final DateUnit startIso = new DateUnit( 1943, 4, 14, java.util.Calendar.WEDNESDAY, true );
+ private static final DateTimeUnit startIso = new DateTimeUnit( 1943, 4, 14, java.util.Calendar.WEDNESDAY, true );
private static final Calendar self = new NepaliCalendar();
@@ -65,64 +65,64 @@
}
@Override
- public DateUnit toIso( DateUnit dateUnit )
+ public DateTimeUnit toIso( DateTimeUnit dateTimeUnit )
{
- if ( dateUnit.isIso8601() )
+ if ( dateTimeUnit.isIso8601() )
{
- return dateUnit;
+ return dateTimeUnit;
}
DateTime dateTime = startIso.toDateTime();
int totalDays = 0;
- for ( int year = startNepal.getYear(); year < dateUnit.getYear(); year++ )
+ for ( int year = startNepal.getYear(); year < dateTimeUnit.getYear(); year++ )
{
totalDays += getYearTotal( year );
}
- for ( int month = startNepal.getMonth(); month < dateUnit.getMonth(); month++ )
+ for ( int month = startNepal.getMonth(); month < dateTimeUnit.getMonth(); month++ )
{
- totalDays += conversionMap.get( dateUnit.getYear() )[month];
+ totalDays += conversionMap.get( dateTimeUnit.getYear() )[month];
}
- totalDays += dateUnit.getDay() - startNepal.getDay();
+ totalDays += dateTimeUnit.getDay() - startNepal.getDay();
dateTime = dateTime.plusDays( totalDays );
- return new DateUnit( DateUnit.fromDateTime( dateTime ), true );
+ return new DateTimeUnit( DateTimeUnit.fromJodaDateTime( dateTime ), true );
}
@Override
- public DateUnit fromIso( DateUnit dateUnit )
+ public DateTimeUnit fromIso( DateTimeUnit dateTimeUnit )
{
DateTime start = startIso.toDateTime();
- DateTime end = dateUnit.toDateTime();
+ DateTime end = dateTimeUnit.toDateTime();
return plusDays( startNepal, Days.daysBetween( start, end ).getDays() );
}
@Override
- public DateInterval toInterval( DateUnit dateUnit, DateIntervalType type, int offset, int length )
+ public DateInterval toInterval( DateTimeUnit dateTimeUnit, DateIntervalType type, int offset, int length )
{
switch ( type )
{
case ISO8601_YEAR:
- return toYearIsoInterval( dateUnit, offset, length );
+ return toYearIsoInterval( dateTimeUnit, offset, length );
case ISO8601_MONTH:
- return toMonthIsoInterval( dateUnit, offset, length );
+ return toMonthIsoInterval( dateTimeUnit, offset, length );
case ISO8601_WEEK:
- return toWeekIsoInterval( dateUnit, offset, length );
+ return toWeekIsoInterval( dateTimeUnit, offset, length );
case ISO8601_DAY:
- return toDayIsoInterval( dateUnit, offset, length );
+ return toDayIsoInterval( dateTimeUnit, offset, length );
}
return null;
}
- private DateInterval toYearIsoInterval( DateUnit dateUnit, int offset, int length )
+ private DateInterval toYearIsoInterval( DateTimeUnit dateTimeUnit, int offset, int length )
{
- DateUnit from = new DateUnit( dateUnit );
+ DateTimeUnit from = new DateTimeUnit( dateTimeUnit );
if ( offset > 0 )
{
@@ -133,7 +133,7 @@
from = minusYears( from, -offset );
}
- DateUnit to = new DateUnit( from );
+ DateTimeUnit to = new DateTimeUnit( from );
to = plusYears( to, length );
to = minusDays( to, length );
@@ -143,9 +143,9 @@
return new DateInterval( from, to, DateIntervalType.ISO8601_YEAR );
}
- private DateInterval toMonthIsoInterval( DateUnit dateUnit, int offset, int length )
+ private DateInterval toMonthIsoInterval( DateTimeUnit dateTimeUnit, int offset, int length )
{
- DateUnit from = new DateUnit( dateUnit );
+ DateTimeUnit from = new DateTimeUnit( dateTimeUnit );
if ( offset > 0 )
{
@@ -156,7 +156,7 @@
from = minusMonths( from, -offset );
}
- DateUnit to = new DateUnit( from );
+ DateTimeUnit to = new DateTimeUnit( from );
to = plusMonths( to, length );
to = minusDays( to, 1 );
@@ -166,9 +166,9 @@
return new DateInterval( from, to, DateIntervalType.ISO8601_MONTH );
}
- private DateInterval toWeekIsoInterval( DateUnit dateUnit, int offset, int length )
+ private DateInterval toWeekIsoInterval( DateTimeUnit dateTimeUnit, int offset, int length )
{
- DateUnit from = new DateUnit( dateUnit );
+ DateTimeUnit from = new DateTimeUnit( dateTimeUnit );
if ( offset > 0 )
{
@@ -179,7 +179,7 @@
from = minusWeeks( from, -offset );
}
- DateUnit to = new DateUnit( from );
+ DateTimeUnit to = new DateTimeUnit( from );
to = plusWeeks( to, length );
to = minusDays( to, 1 );
@@ -189,9 +189,9 @@
return new DateInterval( from, to, DateIntervalType.ISO8601_WEEK );
}
- private DateInterval toDayIsoInterval( DateUnit dateUnit, int offset, int length )
+ private DateInterval toDayIsoInterval( DateTimeUnit dateTimeUnit, int offset, int length )
{
- DateUnit from = new DateUnit( dateUnit );
+ DateTimeUnit from = new DateTimeUnit( dateTimeUnit );
if ( offset > 0 )
{
@@ -202,7 +202,7 @@
from = minusDays( from, -offset );
}
- DateUnit to = new DateUnit( from );
+ DateTimeUnit to = new DateTimeUnit( from );
to = plusDays( to, length );
from = toIso( from );
@@ -231,29 +231,29 @@
}
@Override
- public int isoWeek( DateUnit dateUnit )
+ public int isoWeek( DateTimeUnit dateTimeUnit )
{
- DateTime dateTime = toIso( dateUnit ).toDateTime( ISOChronology.getInstance() );
+ DateTime dateTime = toIso( dateTimeUnit ).toJodaDateTime( ISOChronology.getInstance() );
return dateTime.getWeekyear();
}
@Override
- public int week( DateUnit dateUnit )
+ public int week( DateTimeUnit dateTimeUnit )
{
- return isoWeek( dateUnit );
+ return isoWeek( dateTimeUnit );
}
@Override
- public int isoWeekday( DateUnit dateUnit )
+ public int isoWeekday( DateTimeUnit dateTimeUnit )
{
- DateTime dateTime = toIso( dateUnit ).toDateTime( ISOChronology.getInstance() );
+ DateTime dateTime = toIso( dateTimeUnit ).toJodaDateTime( ISOChronology.getInstance() );
return dateTime.getDayOfWeek();
}
@Override
- public int weekday( DateUnit dateUnit )
+ public int weekday( DateTimeUnit dateTimeUnit )
{
- int dayOfWeek = (isoWeekday( dateUnit ) + 1);
+ int dayOfWeek = (isoWeekday( dateTimeUnit ) + 1);
if ( dayOfWeek > 7 )
{
@@ -322,18 +322,18 @@
}
@Override
- public DateUnit minusYears( DateUnit dateUnit, int years )
+ public DateTimeUnit minusYears( DateTimeUnit dateTimeUnit, int years )
{
- DateUnit result = new DateUnit( dateUnit.getYear() - years, dateUnit.getMonth(), dateUnit.getDay(), dateUnit.getDayOfWeek() );
+ DateTimeUnit result = new DateTimeUnit( dateTimeUnit.getYear() - years, dateTimeUnit.getMonth(), dateTimeUnit.getDay(), dateTimeUnit.getDayOfWeek() );
updateDateUnit( result );
return result;
}
@Override
- public DateUnit minusMonths( DateUnit dateUnit, int months )
+ public DateTimeUnit minusMonths( DateTimeUnit dateTimeUnit, int months )
{
- DateUnit result = new DateUnit( dateUnit );
+ DateTimeUnit result = new DateTimeUnit( dateTimeUnit );
while ( months != 0 )
{
@@ -354,18 +354,18 @@
}
@Override
- public DateUnit minusWeeks( DateUnit dateUnit, int weeks )
+ public DateTimeUnit minusWeeks( DateTimeUnit dateTimeUnit, int weeks )
{
- return minusDays( dateUnit, weeks * daysInWeek() );
+ return minusDays( dateTimeUnit, weeks * daysInWeek() );
}
@Override
- public DateUnit minusDays( DateUnit dateUnit, int days )
+ public DateTimeUnit minusDays( DateTimeUnit dateTimeUnit, int days )
{
- int curYear = dateUnit.getYear();
- int curMonth = dateUnit.getMonth();
- int curDay = dateUnit.getDay();
- int dayOfWeek = dateUnit.getDayOfWeek();
+ int curYear = dateTimeUnit.getYear();
+ int curMonth = dateTimeUnit.getMonth();
+ int curDay = dateTimeUnit.getDay();
+ int dayOfWeek = dateTimeUnit.getDayOfWeek();
while ( days != 0 )
{
@@ -394,22 +394,22 @@
days--;
}
- return new DateUnit( curYear, curMonth, curDay, dayOfWeek );
+ return new DateTimeUnit( curYear, curMonth, curDay, dayOfWeek );
}
@Override
- public DateUnit plusYears( DateUnit dateUnit, int years )
+ public DateTimeUnit plusYears( DateTimeUnit dateTimeUnit, int years )
{
- DateUnit result = new DateUnit( dateUnit.getYear() + years, dateUnit.getMonth(), dateUnit.getDay(), dateUnit.getDayOfWeek() );
+ DateTimeUnit result = new DateTimeUnit( dateTimeUnit.getYear() + years, dateTimeUnit.getMonth(), dateTimeUnit.getDay(), dateTimeUnit.getDayOfWeek() );
updateDateUnit( result );
return result;
}
@Override
- public DateUnit plusMonths( DateUnit dateUnit, int months )
+ public DateTimeUnit plusMonths( DateTimeUnit dateTimeUnit, int months )
{
- DateUnit result = new DateUnit( dateUnit );
+ DateTimeUnit result = new DateTimeUnit( dateTimeUnit );
while ( months != 0 )
{
@@ -430,18 +430,18 @@
}
@Override
- public DateUnit plusWeeks( DateUnit dateUnit, int weeks )
+ public DateTimeUnit plusWeeks( DateTimeUnit dateTimeUnit, int weeks )
{
- return plusDays( dateUnit, weeks * daysInWeek() );
+ return plusDays( dateTimeUnit, weeks * daysInWeek() );
}
@Override
- public DateUnit plusDays( DateUnit dateUnit, int days )
+ public DateTimeUnit plusDays( DateTimeUnit dateTimeUnit, int days )
{
- int curYear = dateUnit.getYear();
- int curMonth = dateUnit.getMonth();
- int curDay = dateUnit.getDay();
- int dayOfWeek = dateUnit.getDayOfWeek();
+ int curYear = dateTimeUnit.getYear();
+ int curMonth = dateTimeUnit.getMonth();
+ int curDay = dateTimeUnit.getDay();
+ int dayOfWeek = dateTimeUnit.getDayOfWeek();
while ( days != 0 )
{
@@ -472,12 +472,12 @@
days--;
}
- return new DateUnit( curYear, curMonth, curDay, dayOfWeek );
+ return new DateTimeUnit( curYear, curMonth, curDay, dayOfWeek );
}
// check if day is more than current maximum for month, don't overflow, just set to maximum
// set day of week
- private void updateDateUnit( DateUnit result )
+ private void updateDateUnit( DateTimeUnit result )
{
int dm = conversionMap.get( result.getYear() )[result.getMonth()];
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java 2014-08-08 07:44:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java 2014-08-29 10:02:21 +0000
@@ -28,7 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.period.WeeklyPeriodType;
@@ -237,8 +237,8 @@
Date periodStartDate = period.getStartDate();
Date periodEndDate = period.getEndDate();
- DateUnit start = PeriodType.getCalendar().fromIso( DateUnit.fromJdkDate( periodStartDate ) );
- DateUnit end = PeriodType.getCalendar().fromIso( DateUnit.fromJdkDate( periodEndDate ) );
+ DateTimeUnit start = PeriodType.getCalendar().fromIso( DateTimeUnit.fromJdkDate( periodStartDate ) );
+ DateTimeUnit end = PeriodType.getCalendar().fromIso( DateTimeUnit.fromJdkDate( periodEndDate ) );
String startDate;
String endDate;
@@ -249,8 +249,8 @@
start.setDay( 1 );
end.setDay( 1 );
- startDate = commonFormatting( new DateUnit( start, true ).toJdkDate(), startPattern );
- endDate = commonFormatting( new DateUnit( end, true ).toJdkDate(), endPattern );
+ startDate = commonFormatting( new DateTimeUnit( start, true ).toJdkDate(), startPattern );
+ endDate = commonFormatting( new DateTimeUnit( end, true ).toJdkDate(), endPattern );
}
else
{
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/BiMonthlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/BiMonthlyPeriodType.java 2014-08-20 10:58:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/BiMonthlyPeriodType.java 2014-08-29 10:02:21 +0000
@@ -30,7 +30,7 @@
import com.google.common.collect.Lists;
import org.hisp.dhis.calendar.Calendar;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import java.util.Date;
import java.util.List;
@@ -61,13 +61,13 @@
}
@Override
- public Period createPeriod( DateUnit dateUnit, Calendar calendar )
+ public Period createPeriod( DateTimeUnit dateTimeUnit, Calendar calendar )
{
- DateUnit start = new DateUnit( dateUnit );
+ DateTimeUnit start = new DateTimeUnit( dateTimeUnit );
start.setMonth( ((start.getMonth() - 1) - (start.getMonth() - 1) % 2) + 1 );
start.setDay( 1 );
- DateUnit end = new DateUnit( start );
+ DateTimeUnit end = new DateTimeUnit( start );
end = calendar.plusMonths( end, 1 );
end.setDay( calendar.daysInMonth( end.getYear(), end.getMonth() ) );
@@ -88,19 +88,19 @@
@Override
public Period getNextPeriod( Period period, Calendar calendar )
{
- DateUnit dateUnit = calendar.fromIso( DateUnit.fromJdkDate( period.getStartDate() ) );
- dateUnit = calendar.plusMonths( dateUnit, 2 );
+ DateTimeUnit dateTimeUnit = calendar.fromIso( DateTimeUnit.fromJdkDate( period.getStartDate() ) );
+ dateTimeUnit = calendar.plusMonths( dateTimeUnit, 2 );
- return createPeriod( calendar.toIso( dateUnit ), calendar );
+ return createPeriod( calendar.toIso( dateTimeUnit ), calendar );
}
@Override
public Period getPreviousPeriod( Period period, Calendar calendar )
{
- DateUnit dateUnit = calendar.fromIso( DateUnit.fromJdkDate( period.getStartDate() ) );
- dateUnit = calendar.minusMonths( dateUnit, 2 );
+ DateTimeUnit dateTimeUnit = calendar.fromIso( DateTimeUnit.fromJdkDate( period.getStartDate() ) );
+ dateTimeUnit = calendar.minusMonths( dateTimeUnit, 2 );
- return createPeriod( calendar.toIso( dateUnit ), calendar );
+ return createPeriod( calendar.toIso( dateTimeUnit ), calendar );
}
/**
@@ -108,21 +108,21 @@
* the given Period exists.
*/
@Override
- public List<Period> generatePeriods( DateUnit dateUnit )
+ public List<Period> generatePeriods( DateTimeUnit dateTimeUnit )
{
Calendar cal = getCalendar();
- dateUnit.setMonth( 1 );
- dateUnit.setDay( 1 );
+ dateTimeUnit.setMonth( 1 );
+ dateTimeUnit.setDay( 1 );
List<Period> periods = Lists.newArrayList();
- int year = dateUnit.getYear();
+ int year = dateTimeUnit.getYear();
- while ( dateUnit.getYear() == year )
+ while ( dateTimeUnit.getYear() == year )
{
- periods.add( createPeriod( dateUnit, cal ) );
- dateUnit = cal.plusMonths( dateUnit, 2 );
+ periods.add( createPeriod( dateTimeUnit, cal ) );
+ dateTimeUnit = cal.plusMonths( dateTimeUnit, 2 );
}
return periods;
@@ -133,28 +133,28 @@
* which the given date is inside.
*/
@Override
- public List<Period> generateRollingPeriods( DateUnit dateUnit )
+ public List<Period> generateRollingPeriods( DateTimeUnit dateTimeUnit )
{
Calendar cal = getCalendar();
- dateUnit.setDay( 1 );
- dateUnit = cal.minusMonths( dateUnit, (dateUnit.getMonth() % 2) + 10 );
+ dateTimeUnit.setDay( 1 );
+ dateTimeUnit = cal.minusMonths( dateTimeUnit, (dateTimeUnit.getMonth() % 2) + 10 );
List<Period> periods = Lists.newArrayList();
for ( int i = 0; i < 6; i++ )
{
- periods.add( createPeriod( dateUnit, cal ) );
- dateUnit = cal.plusMonths( dateUnit, 2 );
+ periods.add( createPeriod( dateTimeUnit, cal ) );
+ dateTimeUnit = cal.plusMonths( dateTimeUnit, 2 );
}
return periods;
}
@Override
- public String getIsoDate( DateUnit dateUnit )
+ public String getIsoDate( DateTimeUnit dateTimeUnit )
{
- return String.format( "%d%02dB", dateUnit.getYear(), (dateUnit.getMonth() + 1) / 2 );
+ return String.format( "%d%02dB", dateTimeUnit.getYear(), (dateTimeUnit.getMonth() + 1) / 2 );
}
@Override
@@ -171,9 +171,9 @@
date = date != null ? date : new Date();
rewindedPeriods = rewindedPeriods != null ? rewindedPeriods : 1;
- DateUnit dateUnit = cal.fromIso( DateUnit.fromJdkDate( date ) );
- dateUnit = cal.minusMonths( dateUnit, rewindedPeriods );
+ DateTimeUnit dateTimeUnit = cal.fromIso( DateTimeUnit.fromJdkDate( date ) );
+ dateTimeUnit = cal.minusMonths( dateTimeUnit, rewindedPeriods );
- return cal.toIso( dateUnit ).toJdkDate();
+ return cal.toIso( dateTimeUnit ).toJdkDate();
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Cal.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Cal.java 2014-06-27 08:25:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Cal.java 2014-08-29 10:02:21 +0000
@@ -29,7 +29,7 @@
*/
import org.hisp.dhis.calendar.CalendarService;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import org.hisp.dhis.calendar.impl.Iso8601Calendar;
import java.util.Calendar;
@@ -61,11 +61,11 @@
return Iso8601Calendar.getInstance();
}
- private DateUnit dateUnit = new DateUnit( 1, 1, 1 );
+ private DateTimeUnit dateTimeUnit = new DateTimeUnit( 1, 1, 1 );
public Cal()
{
- dateUnit = getCalendar().today();
+ dateTimeUnit = getCalendar().today();
}
/**
@@ -75,7 +75,7 @@
*/
public Cal( int year, int month, int day )
{
- dateUnit = new DateUnit( year, month, day );
+ dateTimeUnit = new DateTimeUnit( year, month, day );
}
/**
@@ -86,7 +86,7 @@
*/
public Cal( int year, int month, int day, boolean iso8601 )
{
- dateUnit = new DateUnit( year, month, day, iso8601 );
+ dateTimeUnit = new DateTimeUnit( year, month, day, iso8601 );
}
/**
@@ -94,7 +94,7 @@
*/
public Cal( Date date )
{
- dateUnit = DateUnit.fromJdkDate( date );
+ dateTimeUnit = DateTimeUnit.fromJdkDate( date );
}
/**
@@ -102,7 +102,7 @@
*/
public Cal now()
{
- dateUnit = getCalendar().today();
+ dateTimeUnit = getCalendar().today();
return this;
}
@@ -117,11 +117,11 @@
switch ( field )
{
case Calendar.YEAR:
- getCalendar().plusYears( dateUnit, amount );
+ getCalendar().plusYears( dateTimeUnit, amount );
case Calendar.MONTH:
- getCalendar().plusMonths( dateUnit, amount );
+ getCalendar().plusMonths( dateTimeUnit, amount );
case Calendar.DAY_OF_MONTH:
- getCalendar().plusDays( dateUnit, amount );
+ getCalendar().plusDays( dateTimeUnit, amount );
}
return this;
@@ -138,11 +138,11 @@
switch ( field )
{
case Calendar.YEAR:
- getCalendar().minusYears( dateUnit, amount );
+ getCalendar().minusYears( dateTimeUnit, amount );
case Calendar.MONTH:
- getCalendar().minusMonths( dateUnit, amount );
+ getCalendar().minusMonths( dateTimeUnit, amount );
case Calendar.DAY_OF_MONTH:
- getCalendar().minusDays( dateUnit, amount );
+ getCalendar().minusDays( dateTimeUnit, amount );
}
return this;
@@ -155,7 +155,7 @@
*/
public int get( int field )
{
- return getCalendar().toIso( dateUnit ).toJdkCalendar().get( field );
+ return getCalendar().toIso( dateTimeUnit ).toJdkCalendar().get( field );
}
/**
@@ -165,7 +165,7 @@
*/
public int getYear()
{
- return getCalendar().toIso( dateUnit ).toJdkCalendar().get( Calendar.YEAR );
+ return getCalendar().toIso( dateTimeUnit ).toJdkCalendar().get( Calendar.YEAR );
}
/**
@@ -177,7 +177,7 @@
*/
public Cal set( int year, int month, int day )
{
- dateUnit = new DateUnit( year, month, day );
+ dateTimeUnit = new DateTimeUnit( year, month, day );
return this;
}
@@ -189,8 +189,8 @@
*/
public Cal set( int month, int day )
{
- dateUnit.setMonth( month );
- dateUnit.setDay( day );
+ dateTimeUnit.setMonth( month );
+ dateTimeUnit.setDay( day );
return this;
}
@@ -201,7 +201,7 @@
*/
public Cal set( Date date )
{
- dateUnit = getCalendar().fromIso( DateUnit.fromJdkDate( date ) );
+ dateTimeUnit = getCalendar().fromIso( DateTimeUnit.fromJdkDate( date ) );
return this;
}
@@ -210,6 +210,6 @@
*/
public Date time()
{
- return getCalendar().toIso( dateUnit ).toJdkDate();
+ return getCalendar().toIso( dateTimeUnit ).toJdkDate();
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/CalendarPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/CalendarPeriodType.java 2014-08-21 07:39:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/CalendarPeriodType.java 2014-08-29 10:02:21 +0000
@@ -30,7 +30,7 @@
import com.google.common.collect.Lists;
import org.hisp.dhis.calendar.Calendar;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import java.util.ArrayList;
import java.util.Date;
@@ -134,14 +134,14 @@
return generatePeriods( createLocalDateUnitInstance( date ) );
}
- public abstract List<Period> generatePeriods( DateUnit dateUnit );
+ public abstract List<Period> generatePeriods( DateTimeUnit dateTimeUnit );
public List<Period> generateRollingPeriods( Date date )
{
return generateRollingPeriods( createLocalDateUnitInstance( date ) );
}
- public abstract List<Period> generateRollingPeriods( DateUnit dateUnit );
+ public abstract List<Period> generateRollingPeriods( DateTimeUnit dateTimeUnit );
/**
* Generates a list of Periods for the last 5 years. Must be overridden by
@@ -153,16 +153,16 @@
*/
public List<Period> generateLast5Years( Date date )
{
- DateUnit dateUnit = createLocalDateUnitInstance( date );
- dateUnit = getCalendar().minusYears( dateUnit, 4 );
+ DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( date );
+ dateTimeUnit = getCalendar().minusYears( dateTimeUnit, 4 );
List<Period> periods = Lists.newArrayList();
Calendar calendar = getCalendar();
for ( int i = 0; i < 5; i++ )
{
- periods.addAll( generatePeriods( dateUnit ) );
- dateUnit = calendar.plusYears( dateUnit, 1 );
+ periods.addAll( generatePeriods( dateTimeUnit ) );
+ dateTimeUnit = calendar.plusYears( dateTimeUnit, 1 );
}
return periods;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java 2014-08-21 07:44:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/DailyPeriodType.java 2014-08-29 10:02:21 +0000
@@ -30,7 +30,7 @@
import com.google.common.collect.Lists;
import org.hisp.dhis.calendar.Calendar;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import java.util.Date;
import java.util.List;
@@ -69,9 +69,9 @@
}
@Override
- public Period createPeriod( DateUnit dateUnit, Calendar calendar )
+ public Period createPeriod( DateTimeUnit dateTimeUnit, Calendar calendar )
{
- return toIsoPeriod( dateUnit );
+ return toIsoPeriod( dateTimeUnit );
}
@Override
@@ -87,10 +87,10 @@
@Override
public Period getNextPeriod( Period period, Calendar calendar )
{
- DateUnit dateUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
- dateUnit = calendar.plusDays( dateUnit, 1 );
+ DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
+ dateTimeUnit = calendar.plusDays( dateTimeUnit, 1 );
- Date date = calendar.toIso( dateUnit ).toJdkDate();
+ Date date = calendar.toIso( dateTimeUnit ).toJdkDate();
return new Period( this, date, date );
}
@@ -98,10 +98,10 @@
@Override
public Period getPreviousPeriod( Period period, Calendar calendar )
{
- DateUnit dateUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
- dateUnit = calendar.minusDays( dateUnit, 1 );
+ DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
+ dateTimeUnit = calendar.minusDays( dateTimeUnit, 1 );
- Date date = calendar.toIso( dateUnit ).toJdkDate();
+ Date date = calendar.toIso( dateTimeUnit ).toJdkDate();
return new Period( this, date, date );
}
@@ -111,21 +111,21 @@
* startDate exists.
*/
@Override
- public List<Period> generatePeriods( DateUnit dateUnit )
+ public List<Period> generatePeriods( DateTimeUnit dateTimeUnit )
{
- dateUnit.setMonth( 1 );
- dateUnit.setDay( 1 );
+ dateTimeUnit.setMonth( 1 );
+ dateTimeUnit.setDay( 1 );
List<Period> periods = Lists.newArrayList();
- int year = dateUnit.getYear();
+ int year = dateTimeUnit.getYear();
Calendar calendar = getCalendar();
- while ( year == dateUnit.getYear() )
+ while ( year == dateTimeUnit.getYear() )
{
- periods.add( createPeriod( dateUnit, null ) );
- dateUnit = calendar.plusDays( dateUnit, 1 );
+ periods.add( createPeriod( dateTimeUnit, null ) );
+ dateTimeUnit = calendar.plusDays( dateTimeUnit, 1 );
}
return periods;
@@ -136,27 +136,27 @@
* date.
*/
@Override
- public List<Period> generateRollingPeriods( DateUnit dateUnit )
+ public List<Period> generateRollingPeriods( DateTimeUnit dateTimeUnit )
{
Calendar cal = getCalendar();
- dateUnit = cal.minusDays( dateUnit, 364 );
+ dateTimeUnit = cal.minusDays( dateTimeUnit, 364 );
List<Period> periods = Lists.newArrayList();
for ( int i = 0; i < 365; i++ )
{
- periods.add( createPeriod( dateUnit, null ) );
- dateUnit = cal.plusDays( dateUnit, 1 );
+ periods.add( createPeriod( dateTimeUnit, null ) );
+ dateTimeUnit = cal.plusDays( dateTimeUnit, 1 );
}
return periods;
}
@Override
- public String getIsoDate( DateUnit dateUnit )
+ public String getIsoDate( DateTimeUnit dateTimeUnit )
{
- return String.format( "%d%02d%02d", dateUnit.getYear(), dateUnit.getMonth(), dateUnit.getDay() );
+ return String.format( "%d%02d%02d", dateTimeUnit.getYear(), dateTimeUnit.getMonth(), dateTimeUnit.getDay() );
}
@Override
@@ -173,9 +173,9 @@
date = date != null ? date : new Date();
rewindedPeriods = rewindedPeriods != null ? rewindedPeriods : 1;
- DateUnit dateUnit = createLocalDateUnitInstance( date, cal );
- dateUnit = cal.minusDays( dateUnit, rewindedPeriods );
+ DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( date, cal );
+ dateTimeUnit = cal.minusDays( dateTimeUnit, rewindedPeriods );
- return cal.toIso( dateUnit ).toJdkDate();
+ return cal.toIso( dateTimeUnit ).toJdkDate();
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialAprilPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialAprilPeriodType.java 2014-05-20 09:52:18 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialAprilPeriodType.java 2014-08-29 10:02:21 +0000
@@ -28,7 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import java.util.Calendar;
@@ -60,9 +60,9 @@
}
@Override
- public String getIsoDate( DateUnit dateUnit )
+ public String getIsoDate( DateTimeUnit dateTimeUnit )
{
- return String.format( "%dApril", dateUnit.getYear() );
+ return String.format( "%dApril", dateTimeUnit.getYear() );
}
@Override
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialJulyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialJulyPeriodType.java 2014-05-20 09:52:18 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialJulyPeriodType.java 2014-08-29 10:02:21 +0000
@@ -28,7 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import java.util.Calendar;
@@ -60,9 +60,9 @@
}
@Override
- public String getIsoDate( DateUnit dateUnit )
+ public String getIsoDate( DateTimeUnit dateTimeUnit )
{
- return String.format( "%dJuly", dateUnit.getYear() );
+ return String.format( "%dJuly", dateTimeUnit.getYear() );
}
@Override
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialOctoberPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialOctoberPeriodType.java 2014-05-20 09:52:18 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialOctoberPeriodType.java 2014-08-29 10:02:21 +0000
@@ -28,7 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import java.util.Calendar;
@@ -60,9 +60,9 @@
}
@Override
- public String getIsoDate( DateUnit dateUnit )
+ public String getIsoDate( DateTimeUnit dateTimeUnit )
{
- return String.format( "%dOct", dateUnit.getYear() );
+ return String.format( "%dOct", dateTimeUnit.getYear() );
}
@Override
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialPeriodType.java 2014-08-21 07:44:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/FinancialPeriodType.java 2014-08-29 10:02:21 +0000
@@ -30,7 +30,7 @@
import com.google.common.collect.Lists;
import org.hisp.dhis.calendar.Calendar;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import java.util.Date;
import java.util.List;
@@ -59,20 +59,20 @@
// -------------------------------------------------------------------------
@Override
- public Period createPeriod( DateUnit dateUnit, Calendar calendar )
+ public Period createPeriod( DateTimeUnit dateTimeUnit, Calendar calendar )
{
- boolean past = dateUnit.getMonth() >= (getBaseMonth() + 1);
+ boolean past = dateTimeUnit.getMonth() >= (getBaseMonth() + 1);
if ( !past )
{
- dateUnit = getCalendar().minusYears( dateUnit, 1 );
+ dateTimeUnit = getCalendar().minusYears( dateTimeUnit, 1 );
}
- dateUnit.setMonth( getBaseMonth() + 1 );
- dateUnit.setDay( 1 );
+ dateTimeUnit.setMonth( getBaseMonth() + 1 );
+ dateTimeUnit.setDay( 1 );
- DateUnit start = new DateUnit( dateUnit );
- DateUnit end = new DateUnit( dateUnit );
+ DateTimeUnit start = new DateTimeUnit( dateTimeUnit );
+ DateTimeUnit end = new DateTimeUnit( dateTimeUnit );
end = getCalendar().plusYears( end, 1 );
end = getCalendar().minusDays( end, 1 );
@@ -93,19 +93,19 @@
@Override
public Period getNextPeriod( Period period, Calendar calendar )
{
- DateUnit dateUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
- dateUnit = calendar.plusYears( dateUnit, 1 );
+ DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
+ dateTimeUnit = calendar.plusYears( dateTimeUnit, 1 );
- return createPeriod( dateUnit, calendar );
+ return createPeriod( dateTimeUnit, calendar );
}
@Override
public Period getPreviousPeriod( Period period, Calendar calendar )
{
- DateUnit dateUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
- dateUnit = calendar.minusYears( dateUnit, 1 );
+ DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
+ dateTimeUnit = calendar.minusYears( dateTimeUnit, 1 );
- return createPeriod( dateUnit, calendar );
+ return createPeriod( dateTimeUnit, calendar );
}
/**
@@ -113,24 +113,24 @@
* financial years.
*/
@Override
- public List<Period> generatePeriods( DateUnit dateUnit )
+ public List<Period> generatePeriods( DateTimeUnit dateTimeUnit )
{
Calendar cal = getCalendar();
- boolean past = dateUnit.getMonth() >= (getBaseMonth() + 1);
+ boolean past = dateTimeUnit.getMonth() >= (getBaseMonth() + 1);
List<Period> periods = Lists.newArrayList();
- dateUnit = cal.minusYears( dateUnit, past ? 5 : 6 );
- dateUnit.setMonth( getBaseMonth() + 1 );
- dateUnit.setDay( 1 );
+ dateTimeUnit = cal.minusYears( dateTimeUnit, past ? 5 : 6 );
+ dateTimeUnit.setMonth( getBaseMonth() + 1 );
+ dateTimeUnit.setDay( 1 );
Calendar calendar = getCalendar();
for ( int i = 0; i < 11; i++ )
{
- periods.add( createPeriod( dateUnit, cal ) );
- dateUnit = calendar.plusYears( dateUnit, 1 );
+ periods.add( createPeriod( dateTimeUnit, cal ) );
+ dateTimeUnit = calendar.plusYears( dateTimeUnit, 1 );
}
return periods;
@@ -147,9 +147,9 @@
}
@Override
- public List<Period> generateRollingPeriods( DateUnit dateUnit )
+ public List<Period> generateRollingPeriods( DateTimeUnit dateTimeUnit )
{
- return generateLast5Years( getCalendar().toIso( dateUnit ).toJdkDate() );
+ return generateLast5Years( getCalendar().toIso( dateTimeUnit ).toJdkDate() );
}
@Override
@@ -157,19 +157,19 @@
{
Calendar cal = getCalendar();
- DateUnit dateUnit = createLocalDateUnitInstance( date, cal );
- boolean past = dateUnit.getMonth() >= (getBaseMonth() + 1);
+ DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( date, cal );
+ boolean past = dateTimeUnit.getMonth() >= (getBaseMonth() + 1);
List<Period> periods = Lists.newArrayList();
- dateUnit = cal.minusYears( dateUnit, past ? 4 : 5 );
- dateUnit.setMonth( getBaseMonth() + 1 );
- dateUnit.setDay( 1 );
+ dateTimeUnit = cal.minusYears( dateTimeUnit, past ? 4 : 5 );
+ dateTimeUnit.setMonth( getBaseMonth() + 1 );
+ dateTimeUnit.setDay( 1 );
for ( int i = 0; i < 5; i++ )
{
- periods.add( createPeriod( dateUnit, cal ) );
- dateUnit = cal.plusYears( dateUnit, 1 );
+ periods.add( createPeriod( dateTimeUnit, cal ) );
+ dateTimeUnit = cal.plusYears( dateTimeUnit, 1 );
}
return periods;
@@ -183,9 +183,9 @@
date = date != null ? date : new Date();
rewindedPeriods = rewindedPeriods != null ? rewindedPeriods : 1;
- DateUnit dateUnit = createLocalDateUnitInstance( date, cal );
- dateUnit = cal.minusYears( dateUnit, rewindedPeriods );
+ DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( date, cal );
+ dateTimeUnit = cal.minusYears( dateTimeUnit, rewindedPeriods );
- return cal.toIso( dateUnit ).toJdkDate();
+ return cal.toIso( dateTimeUnit ).toJdkDate();
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java 2014-08-20 10:58:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/MonthlyPeriodType.java 2014-08-29 10:02:21 +0000
@@ -30,7 +30,7 @@
import com.google.common.collect.Lists;
import org.hisp.dhis.calendar.Calendar;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import java.util.Date;
import java.util.List;
@@ -71,12 +71,12 @@
}
@Override
- public Period createPeriod( DateUnit dateUnit, Calendar calendar )
+ public Period createPeriod( DateTimeUnit dateTimeUnit, Calendar calendar )
{
- DateUnit start = new DateUnit( dateUnit );
+ DateTimeUnit start = new DateTimeUnit( dateTimeUnit );
start.setDay( 1 );
- DateUnit end = new DateUnit( dateUnit );
+ DateTimeUnit end = new DateTimeUnit( dateTimeUnit );
end.setDay( calendar.daysInMonth( end.getYear(), end.getMonth() ) );
return toIsoPeriod( start, end, calendar );
@@ -95,19 +95,19 @@
@Override
public Period getNextPeriod( Period period, Calendar calendar )
{
- DateUnit dateUnit = calendar.fromIso( DateUnit.fromJdkDate( period.getStartDate() ) );
- dateUnit = calendar.plusMonths( dateUnit, 1 );
+ DateTimeUnit dateTimeUnit = calendar.fromIso( DateTimeUnit.fromJdkDate( period.getStartDate() ) );
+ dateTimeUnit = calendar.plusMonths( dateTimeUnit, 1 );
- return createPeriod( calendar.toIso( dateUnit ), calendar );
+ return createPeriod( calendar.toIso( dateTimeUnit ), calendar );
}
@Override
public Period getPreviousPeriod( Period period, Calendar calendar )
{
- DateUnit dateUnit = calendar.fromIso( DateUnit.fromJdkDate( period.getStartDate() ) );
- dateUnit = calendar.minusMonths( dateUnit, 1 );
+ DateTimeUnit dateTimeUnit = calendar.fromIso( DateTimeUnit.fromJdkDate( period.getStartDate() ) );
+ dateTimeUnit = calendar.minusMonths( dateTimeUnit, 1 );
- return createPeriod( calendar.toIso( dateUnit ), calendar );
+ return createPeriod( calendar.toIso( dateTimeUnit ), calendar );
}
/**
@@ -115,21 +115,21 @@
* startDate exists.
*/
@Override
- public List<Period> generatePeriods( DateUnit dateUnit )
+ public List<Period> generatePeriods( DateTimeUnit dateTimeUnit )
{
Calendar cal = getCalendar();
- dateUnit.setMonth( 1 );
- dateUnit.setDay( 1 );
+ dateTimeUnit.setMonth( 1 );
+ dateTimeUnit.setDay( 1 );
List<Period> periods = Lists.newArrayList();
- int year = dateUnit.getYear();
+ int year = dateTimeUnit.getYear();
- while ( dateUnit.getYear() == year )
+ while ( dateTimeUnit.getYear() == year )
{
- periods.add( createPeriod( dateUnit, cal ) );
- dateUnit = cal.plusMonths( dateUnit, 1 );
+ periods.add( createPeriod( dateTimeUnit, cal ) );
+ dateTimeUnit = cal.plusMonths( dateTimeUnit, 1 );
}
return periods;
@@ -140,28 +140,28 @@
* given date is inside.
*/
@Override
- public List<Period> generateRollingPeriods( DateUnit dateUnit )
+ public List<Period> generateRollingPeriods( DateTimeUnit dateTimeUnit )
{
Calendar cal = getCalendar();
- dateUnit.setDay( 1 );
- dateUnit = cal.minusMonths( dateUnit, 11 );
+ dateTimeUnit.setDay( 1 );
+ dateTimeUnit = cal.minusMonths( dateTimeUnit, 11 );
List<Period> periods = Lists.newArrayList();
for ( int i = 0; i < 12; i++ )
{
- periods.add( createPeriod( dateUnit, cal ) );
- dateUnit = cal.plusMonths( dateUnit, 1 );
+ periods.add( createPeriod( dateTimeUnit, cal ) );
+ dateTimeUnit = cal.plusMonths( dateTimeUnit, 1 );
}
return periods;
}
@Override
- public String getIsoDate( DateUnit dateUnit )
+ public String getIsoDate( DateTimeUnit dateTimeUnit )
{
- return String.format( "%d%02d", dateUnit.getYear(), dateUnit.getMonth() );
+ return String.format( "%d%02d", dateTimeUnit.getYear(), dateTimeUnit.getMonth() );
}
@Override
@@ -178,9 +178,9 @@
date = date != null ? date : new Date();
rewindedPeriods = rewindedPeriods != null ? rewindedPeriods : 1;
- DateUnit dateUnit = cal.fromIso( DateUnit.fromJdkDate( date ) );
- dateUnit = cal.minusMonths( dateUnit, rewindedPeriods );
+ DateTimeUnit dateTimeUnit = cal.fromIso( DateTimeUnit.fromJdkDate( date ) );
+ dateTimeUnit = cal.minusMonths( dateTimeUnit, rewindedPeriods );
- return cal.toIso( dateUnit ).toJdkDate();
+ return cal.toIso( dateTimeUnit ).toJdkDate();
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java 2014-08-26 08:03:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/PeriodType.java 2014-08-29 10:02:21 +0000
@@ -33,7 +33,7 @@
import com.google.common.cache.CacheBuilder;
import org.hisp.dhis.calendar.CalendarService;
import org.hisp.dhis.calendar.DateInterval;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import org.hisp.dhis.calendar.DateUnitPeriodTypeParser;
import org.hisp.dhis.calendar.DateUnitType;
import org.hisp.dhis.calendar.PeriodTypeParser;
@@ -264,7 +264,7 @@
{
org.hisp.dhis.calendar.Calendar calendar = getCalendar();
- return createPeriod( calendar.fromIso( DateUnit.fromJdkCalendar( cal ) ), calendar );
+ return createPeriod( calendar.fromIso( DateTimeUnit.fromJdkCalendar( cal ) ), calendar );
}
/**
@@ -286,7 +286,7 @@
@Override
public Period call() throws Exception
{
- return createPeriod( calendar.fromIso( DateUnit.fromJdkDate( date ) ), calendar );
+ return createPeriod( calendar.fromIso( DateTimeUnit.fromJdkDate( date ) ), calendar );
}
} );
}
@@ -297,27 +297,27 @@
return null;
}
- public Period toIsoPeriod( DateUnit start, DateUnit end )
+ public Period toIsoPeriod( DateTimeUnit start, DateTimeUnit end )
{
org.hisp.dhis.calendar.Calendar cal = getCalendar();
return toIsoPeriod( start, end, cal );
}
- protected Period toIsoPeriod( DateUnit start, DateUnit end, org.hisp.dhis.calendar.Calendar calendar )
+ protected Period toIsoPeriod( DateTimeUnit start, DateTimeUnit end, org.hisp.dhis.calendar.Calendar calendar )
{
- DateUnit from = calendar.toIso( start );
- DateUnit to = calendar.toIso( end );
+ DateTimeUnit from = calendar.toIso( start );
+ DateTimeUnit to = calendar.toIso( end );
return new Period( this, from.toJdkDate(), to.toJdkDate(), getIsoDate( from ) );
}
- public Period toIsoPeriod( DateUnit dateUnit )
+ public Period toIsoPeriod( DateTimeUnit dateTimeUnit )
{
- return toIsoPeriod( dateUnit, dateUnit );
+ return toIsoPeriod( dateTimeUnit, dateTimeUnit );
}
- public abstract Period createPeriod( DateUnit dateUnit, org.hisp.dhis.calendar.Calendar calendar );
+ public abstract Period createPeriod( DateTimeUnit dateTimeUnit, org.hisp.dhis.calendar.Calendar calendar );
/**
* Returns a comparable value for the frequency length of this PeriodType.
@@ -374,7 +374,7 @@
* @param date date of calendar in local calendar
* @return an instance of a Calendar without any time of day.
*/
- public static DateUnit createLocalDateUnitInstance( Date date )
+ public static DateTimeUnit createLocalDateUnitInstance( Date date )
{
return createLocalDateUnitInstance( date, getCalendar() );
}
@@ -385,9 +385,9 @@
* @param date date of calendar in local calendar
* @return an instance of a Calendar without any time of day.
*/
- public static DateUnit createLocalDateUnitInstance( Date date, org.hisp.dhis.calendar.Calendar calendar )
+ public static DateTimeUnit createLocalDateUnitInstance( Date date, org.hisp.dhis.calendar.Calendar calendar )
{
- return calendar.fromIso( DateUnit.fromJdkDate( date ) );
+ return calendar.fromIso( DateTimeUnit.fromJdkDate( date ) );
}
/**
@@ -476,8 +476,8 @@
org.hisp.dhis.calendar.Calendar cal = getCalendar();
- final DateUnit from = cal.toIso( dateInterval.getFrom() );
- final DateUnit to = cal.toIso( dateInterval.getTo() );
+ final DateTimeUnit from = cal.toIso( dateInterval.getFrom() );
+ final DateTimeUnit to = cal.toIso( dateInterval.getTo() );
return new Period( this, from.toJdkDate(), to.toJdkDate(), getIsoDate( from ) );
}
@@ -496,10 +496,10 @@
/**
* Returns an iso8601 formatted string representation of the dataUnit
*
- * @param dateUnit Period
+ * @param dateTimeUnit Period
* @return the period as string
*/
- public abstract String getIsoDate( DateUnit dateUnit );
+ public abstract String getIsoDate( DateTimeUnit dateTimeUnit );
/**
* Generates a period based on the given iso8601 formatted string.
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java 2014-08-21 07:44:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/QuarterlyPeriodType.java 2014-08-29 10:02:21 +0000
@@ -29,7 +29,7 @@
*/
import com.google.common.collect.Lists;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import java.util.Calendar;
import java.util.Date;
@@ -71,14 +71,14 @@
}
@Override
- public Period createPeriod( DateUnit dateUnit, org.hisp.dhis.calendar.Calendar calendar )
+ public Period createPeriod( DateTimeUnit dateTimeUnit, org.hisp.dhis.calendar.Calendar calendar )
{
- DateUnit start = new DateUnit( dateUnit );
+ DateTimeUnit start = new DateTimeUnit( dateTimeUnit );
- start.setMonth( ((dateUnit.getMonth() - 1) - ((dateUnit.getMonth() - 1) % 3)) + 1 );
+ start.setMonth( ((dateTimeUnit.getMonth() - 1) - ((dateTimeUnit.getMonth() - 1) % 3)) + 1 );
start.setDay( 1 );
- DateUnit end = new DateUnit( start );
+ DateTimeUnit end = new DateTimeUnit( start );
end = calendar.plusMonths( end, 2 );
end.setDay( calendar.daysInMonth( end.getYear(), end.getMonth() ) );
@@ -98,19 +98,19 @@
@Override
public Period getNextPeriod( Period period, org.hisp.dhis.calendar.Calendar calendar )
{
- DateUnit dateUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
- dateUnit = calendar.plusMonths( dateUnit, 3 );
+ DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
+ dateTimeUnit = calendar.plusMonths( dateTimeUnit, 3 );
- return createPeriod( dateUnit, calendar );
+ return createPeriod( dateTimeUnit, calendar );
}
@Override
public Period getPreviousPeriod( Period period, org.hisp.dhis.calendar.Calendar calendar )
{
- DateUnit dateUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
- dateUnit = calendar.minusMonths( dateUnit, 3 );
+ DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
+ dateTimeUnit = calendar.minusMonths( dateTimeUnit, 3 );
- return createPeriod( dateUnit, calendar );
+ return createPeriod( dateTimeUnit, calendar );
}
/**
@@ -118,20 +118,20 @@
* Period's startDate exists.
*/
@Override
- public List<Period> generatePeriods( DateUnit dateUnit )
+ public List<Period> generatePeriods( DateTimeUnit dateTimeUnit )
{
org.hisp.dhis.calendar.Calendar cal = getCalendar();
- dateUnit.setMonth( 1 );
- dateUnit.setDay( 1 );
+ dateTimeUnit.setMonth( 1 );
+ dateTimeUnit.setDay( 1 );
- int year = dateUnit.getYear();
+ int year = dateTimeUnit.getYear();
List<Period> periods = Lists.newArrayList();
- while ( year == dateUnit.getYear() )
+ while ( year == dateTimeUnit.getYear() )
{
- periods.add( createPeriod( dateUnit, cal ) );
- dateUnit = cal.plusMonths( dateUnit, 3 );
+ periods.add( createPeriod( dateTimeUnit, cal ) );
+ dateTimeUnit = cal.plusMonths( dateTimeUnit, 3 );
}
return periods;
@@ -150,38 +150,38 @@
}
@Override
- public List<Period> generateRollingPeriods( DateUnit dateUnit )
+ public List<Period> generateRollingPeriods( DateTimeUnit dateTimeUnit )
{
org.hisp.dhis.calendar.Calendar cal = getCalendar();
- dateUnit.setDay( 1 );
+ dateTimeUnit.setDay( 1 );
- dateUnit = cal.minusMonths( dateUnit, 9 );
+ dateTimeUnit = cal.minusMonths( dateTimeUnit, 9 );
List<Period> periods = Lists.newArrayList();
for ( int i = 0; i < 4; i++ )
{
- periods.add( createPeriod( dateUnit, cal ) );
- dateUnit = cal.plusMonths( dateUnit, 3 );
+ periods.add( createPeriod( dateTimeUnit, cal ) );
+ dateTimeUnit = cal.plusMonths( dateTimeUnit, 3 );
}
return periods;
}
@Override
- public String getIsoDate( DateUnit dateUnit )
+ public String getIsoDate( DateTimeUnit dateTimeUnit )
{
- switch ( dateUnit.getMonth() )
+ switch ( dateTimeUnit.getMonth() )
{
case 1:
- return dateUnit.getYear() + "Q1";
+ return dateTimeUnit.getYear() + "Q1";
case 4:
- return dateUnit.getYear() + "Q2";
+ return dateTimeUnit.getYear() + "Q2";
case 7:
- return dateUnit.getYear() + "Q3";
+ return dateTimeUnit.getYear() + "Q3";
case 10:
- return dateUnit.getYear() + "Q4";
+ return dateTimeUnit.getYear() + "Q4";
default:
throw new IllegalArgumentException( "Month not valid [1,4,7,10]" );
}
@@ -238,9 +238,9 @@
date = date != null ? date : new Date();
rewindedPeriods = rewindedPeriods != null ? rewindedPeriods : 1;
- DateUnit dateUnit = createLocalDateUnitInstance( date );
- dateUnit = cal.minusMonths( dateUnit, rewindedPeriods * 3 );
+ DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( date );
+ dateTimeUnit = cal.minusMonths( dateTimeUnit, rewindedPeriods * 3 );
- return cal.toIso( dateUnit ).toJdkDate();
+ return cal.toIso( dateTimeUnit ).toJdkDate();
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAbstractPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAbstractPeriodType.java 2014-08-21 07:44:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAbstractPeriodType.java 2014-08-29 10:02:21 +0000
@@ -31,7 +31,7 @@
import com.google.common.collect.Lists;
import org.hisp.dhis.calendar.Calendar;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import java.util.Date;
import java.util.List;
@@ -62,22 +62,22 @@
// -------------------------------------------------------------------------
@Override
- public Period createPeriod( DateUnit dateUnit, Calendar calendar )
+ public Period createPeriod( DateTimeUnit dateTimeUnit, Calendar calendar )
{
- int year = calendar.monthsInYear() * dateUnit.getYear();
- int yearMonth = year + dateUnit.getMonth() - getBaseMonth();
+ int year = calendar.monthsInYear() * dateTimeUnit.getYear();
+ int yearMonth = year + dateTimeUnit.getMonth() - getBaseMonth();
// TODO how should we handle years with odd number of months? (Ethiopian)
int months = (((yearMonth % 12) / 6) * 6) + getBaseMonth();
- DateUnit start = new DateUnit( dateUnit );
+ DateTimeUnit start = new DateTimeUnit( dateTimeUnit );
start.setDay( 1 );
start.setMonth( 1 );
start = calendar.plusMonths( start, months );
start.setDayOfWeek( calendar.weekday( start ) );
- DateUnit end = new DateUnit( start );
+ DateTimeUnit end = new DateTimeUnit( start );
end = calendar.plusMonths( end, 5 );
end.setDay( calendar.daysInMonth( end.getYear(), end.getMonth() ) );
end.setDayOfWeek( calendar.weekday( end ) );
@@ -98,19 +98,19 @@
@Override
public Period getNextPeriod( Period period, Calendar calendar )
{
- DateUnit dateUnit = calendar.fromIso( DateUnit.fromJdkDate( period.getStartDate() ) );
- dateUnit = calendar.plusMonths( dateUnit, 6 );
+ DateTimeUnit dateTimeUnit = calendar.fromIso( DateTimeUnit.fromJdkDate( period.getStartDate() ) );
+ dateTimeUnit = calendar.plusMonths( dateTimeUnit, 6 );
- return createPeriod( calendar.toIso( dateUnit ), calendar );
+ return createPeriod( calendar.toIso( dateTimeUnit ), calendar );
}
@Override
public Period getPreviousPeriod( Period period, Calendar calendar )
{
- DateUnit dateUnit = calendar.fromIso( DateUnit.fromJdkDate( period.getStartDate() ) );
- dateUnit = calendar.minusMonths( dateUnit, 6 );
+ DateTimeUnit dateTimeUnit = calendar.fromIso( DateTimeUnit.fromJdkDate( period.getStartDate() ) );
+ dateTimeUnit = calendar.minusMonths( dateTimeUnit, 6 );
- return createPeriod( calendar.toIso( dateUnit ), calendar );
+ return createPeriod( calendar.toIso( dateTimeUnit ), calendar );
}
/**
@@ -118,16 +118,16 @@
* Period's startDate exists.
*/
@Override
- public List<Period> generatePeriods( DateUnit dateUnit )
+ public List<Period> generatePeriods( DateTimeUnit dateTimeUnit )
{
Calendar cal = getCalendar();
- Period period = createPeriod( dateUnit, cal );
- dateUnit = createLocalDateUnitInstance( period.getStartDate(), cal );
+ Period period = createPeriod( dateTimeUnit, cal );
+ dateTimeUnit = createLocalDateUnitInstance( period.getStartDate(), cal );
List<Period> periods = Lists.newArrayList();
- if ( dateUnit.getMonth() == (getBaseMonth() + 1) )
+ if ( dateTimeUnit.getMonth() == (getBaseMonth() + 1) )
{
periods.add( period );
periods.add( getNextPeriod( period ) );
@@ -159,9 +159,9 @@
}
@Override
- public List<Period> generateRollingPeriods( DateUnit dateUnit )
+ public List<Period> generateRollingPeriods( DateTimeUnit dateTimeUnit )
{
- return generateRollingPeriods( getCalendar().toIso( dateUnit ).toJdkDate() );
+ return generateRollingPeriods( getCalendar().toIso( dateTimeUnit ).toJdkDate() );
}
@Override
@@ -172,9 +172,9 @@
date = date != null ? date : new Date();
rewindedPeriods = rewindedPeriods != null ? rewindedPeriods : 1;
- DateUnit dateUnit = createLocalDateUnitInstance( date );
- cal.minusMonths( dateUnit, rewindedPeriods * 6 );
+ DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( date );
+ cal.minusMonths( dateTimeUnit, rewindedPeriods * 6 );
- return cal.toIso( dateUnit ).toJdkDate();
+ return cal.toIso( dateTimeUnit ).toJdkDate();
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAprilPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAprilPeriodType.java 2014-05-23 15:01:06 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyAprilPeriodType.java 2014-08-29 10:02:21 +0000
@@ -28,7 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import java.util.Calendar;
@@ -77,14 +77,14 @@
// -------------------------------------------------------------------------
@Override
- public String getIsoDate( DateUnit dateUnit )
+ public String getIsoDate( DateTimeUnit dateTimeUnit )
{
- switch ( dateUnit.getMonth() )
+ switch ( dateTimeUnit.getMonth() )
{
case 4:
- return dateUnit.getYear() + "AprilS1";
+ return dateTimeUnit.getYear() + "AprilS1";
case 10:
- return dateUnit.getYear() + "AprilS2";
+ return dateTimeUnit.getYear() + "AprilS2";
default:
throw new IllegalArgumentException( "Month not valid [4,10]" );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java 2014-05-20 09:52:18 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/SixMonthlyPeriodType.java 2014-08-29 10:02:21 +0000
@@ -28,7 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import java.util.Calendar;
@@ -78,14 +78,14 @@
// -------------------------------------------------------------------------
@Override
- public String getIsoDate( DateUnit dateUnit )
+ public String getIsoDate( DateTimeUnit dateTimeUnit )
{
- switch ( dateUnit.getMonth() )
+ switch ( dateTimeUnit.getMonth() )
{
case 1:
- return dateUnit.getYear() + "S1";
+ return dateTimeUnit.getYear() + "S1";
case 7:
- return dateUnit.getYear() + "S2";
+ return dateTimeUnit.getYear() + "S2";
default:
throw new IllegalArgumentException( "Month not valid [1,7]" );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java 2014-08-20 10:58:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/TwoYearlyPeriodType.java 2014-08-29 10:02:21 +0000
@@ -28,7 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import java.util.ArrayList;
import java.util.Calendar;
@@ -83,7 +83,7 @@
}
@Override
- public Period createPeriod( DateUnit dateUnit, org.hisp.dhis.calendar.Calendar calendar )
+ public Period createPeriod( DateTimeUnit dateTimeUnit, org.hisp.dhis.calendar.Calendar calendar )
{
return null;
}
@@ -153,7 +153,7 @@
}
@Override
- public List<Period> generatePeriods( DateUnit dateUnit )
+ public List<Period> generatePeriods( DateTimeUnit dateTimeUnit )
{
return null; // TODO
}
@@ -165,9 +165,9 @@
}
@Override
- public List<Period> generateRollingPeriods( DateUnit dateUnit )
+ public List<Period> generateRollingPeriods( DateTimeUnit dateTimeUnit )
{
- return generateLast5Years( getCalendar().toIso( dateUnit ).toJdkDate() );
+ return generateLast5Years( getCalendar().toIso( dateTimeUnit ).toJdkDate() );
}
@Override
@@ -198,7 +198,7 @@
}
@Override
- public String getIsoDate( DateUnit dateUnit )
+ public String getIsoDate( DateTimeUnit dateTimeUnit )
{
return null; // TODO
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java 2014-08-21 07:44:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java 2014-08-29 10:02:21 +0000
@@ -33,7 +33,7 @@
import org.hisp.dhis.calendar.Calendar;
import org.hisp.dhis.calendar.DateInterval;
import org.hisp.dhis.calendar.DateIntervalType;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import java.util.Date;
import java.util.List;
@@ -74,12 +74,12 @@
}
@Override
- public Period createPeriod( DateUnit dateUnit, Calendar calendar )
+ public Period createPeriod( DateTimeUnit dateTimeUnit, Calendar calendar )
{
- DateUnit start = new DateUnit( dateUnit );
- start = calendar.minusDays( dateUnit, calendar.weekday( start ) - 1 );
+ DateTimeUnit start = new DateTimeUnit( dateTimeUnit );
+ start = calendar.minusDays( dateTimeUnit, calendar.weekday( start ) - 1 );
- DateUnit end = new DateUnit( start );
+ DateTimeUnit end = new DateTimeUnit( start );
end = calendar.plusDays( end, calendar.daysInWeek() - 1 );
return toIsoPeriod( start, end, calendar );
@@ -98,19 +98,19 @@
@Override
public Period getNextPeriod( Period period, Calendar calendar )
{
- DateUnit dateUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
- dateUnit = calendar.plusWeeks( dateUnit, 1 );
+ DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
+ dateTimeUnit = calendar.plusWeeks( dateTimeUnit, 1 );
- return createPeriod( dateUnit, calendar );
+ return createPeriod( dateTimeUnit, calendar );
}
@Override
public Period getPreviousPeriod( Period period, Calendar calendar )
{
- DateUnit dateUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
- dateUnit = calendar.minusWeeks( dateUnit, 1 );
+ DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
+ dateTimeUnit = calendar.minusWeeks( dateTimeUnit, 1 );
- return createPeriod( dateUnit, calendar );
+ return createPeriod( dateTimeUnit, calendar );
}
/**
@@ -118,21 +118,21 @@
* startDate exists.
*/
@Override
- public List<Period> generatePeriods( DateUnit dateUnit )
+ public List<Period> generatePeriods( DateTimeUnit dateTimeUnit )
{
Calendar cal = getCalendar();
List<Period> periods = Lists.newArrayList();
// rewind to start of week
- dateUnit = cal.minusDays( dateUnit, cal.weekday( dateUnit ) - 1 );
+ dateTimeUnit = cal.minusDays( dateTimeUnit, cal.weekday( dateTimeUnit ) - 1 );
- for ( int i = 0; i < cal.weeksInYear( dateUnit.getYear() ); i++ )
+ for ( int i = 0; i < cal.weeksInYear( dateTimeUnit.getYear() ); i++ )
{
- DateInterval interval = cal.toInterval( dateUnit, DateIntervalType.ISO8601_WEEK );
+ DateInterval interval = cal.toInterval( dateTimeUnit, DateIntervalType.ISO8601_WEEK );
periods.add( new Period( this, interval.getFrom().toJdkDate(), interval.getTo().toJdkDate() ) );
- dateUnit = cal.plusWeeks( dateUnit, 1 );
+ dateTimeUnit = cal.plusWeeks( dateTimeUnit, 1 );
}
return periods;
@@ -143,18 +143,18 @@
* given date is inside.
*/
@Override
- public List<Period> generateRollingPeriods( DateUnit dateUnit )
+ public List<Period> generateRollingPeriods( DateTimeUnit dateTimeUnit )
{
Calendar cal = getCalendar();
List<Period> periods = Lists.newArrayList();
- dateUnit = cal.minusDays( dateUnit, cal.weekday( dateUnit ) - 1 );
- dateUnit = cal.minusDays( dateUnit, 357 );
+ dateTimeUnit = cal.minusDays( dateTimeUnit, cal.weekday( dateTimeUnit ) - 1 );
+ dateTimeUnit = cal.minusDays( dateTimeUnit, 357 );
for ( int i = 0; i < 52; i++ )
{
- periods.add( createPeriod( dateUnit, cal ) );
- dateUnit = cal.plusWeeks( dateUnit, 1 );
+ periods.add( createPeriod( dateTimeUnit, cal ) );
+ dateTimeUnit = cal.plusWeeks( dateTimeUnit, 1 );
}
return periods;
@@ -165,18 +165,18 @@
// -------------------------------------------------------------------------
@Override
- public String getIsoDate( DateUnit dateUnit )
+ public String getIsoDate( DateTimeUnit dateTimeUnit )
{
Calendar cal = getCalendar();
- int week = cal.week( dateUnit );
+ int week = cal.week( dateTimeUnit );
- if ( week == 1 && dateUnit.getMonth() == cal.monthsInYear() )
+ if ( week == 1 && dateTimeUnit.getMonth() == cal.monthsInYear() )
{
- dateUnit.setYear( dateUnit.getYear() + 1 );
+ dateTimeUnit.setYear( dateTimeUnit.getYear() + 1 );
}
- return String.format( "%dW%d", dateUnit.getYear(), week );
+ return String.format( "%dW%d", dateTimeUnit.getYear(), week );
}
/**
@@ -196,9 +196,9 @@
date = date != null ? date : new Date();
rewindedPeriods = rewindedPeriods != null ? rewindedPeriods : 1;
- DateUnit dateUnit = createLocalDateUnitInstance( date );
- dateUnit = cal.minusWeeks( dateUnit, rewindedPeriods );
+ DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( date );
+ dateTimeUnit = cal.minusWeeks( dateTimeUnit, rewindedPeriods );
- return cal.toIso( dateUnit ).toJdkDate();
+ return cal.toIso( dateTimeUnit ).toJdkDate();
}
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.java 2014-08-21 07:44:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/YearlyPeriodType.java 2014-08-29 10:02:21 +0000
@@ -31,7 +31,7 @@
import com.google.common.collect.Lists;
import org.hisp.dhis.calendar.Calendar;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import java.util.Date;
import java.util.List;
@@ -71,10 +71,10 @@
}
@Override
- public Period createPeriod( DateUnit dateUnit, Calendar calendar )
+ public Period createPeriod( DateTimeUnit dateTimeUnit, Calendar calendar )
{
- DateUnit start = new DateUnit( dateUnit );
- DateUnit end = new DateUnit( dateUnit );
+ DateTimeUnit start = new DateTimeUnit( dateTimeUnit );
+ DateTimeUnit end = new DateTimeUnit( dateTimeUnit );
start.setDay( 1 );
start.setMonth( 1 );
@@ -98,39 +98,39 @@
@Override
public Period getNextPeriod( Period period, Calendar calendar )
{
- DateUnit dateUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
- dateUnit = calendar.plusYears( dateUnit, 1 );
+ DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
+ dateTimeUnit = calendar.plusYears( dateTimeUnit, 1 );
- return createPeriod( dateUnit, calendar );
+ return createPeriod( dateTimeUnit, calendar );
}
@Override
public Period getPreviousPeriod( Period period, Calendar calendar )
{
- DateUnit dateUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
- dateUnit = calendar.minusYears( dateUnit, 1 );
+ DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( period.getStartDate(), calendar );
+ dateTimeUnit = calendar.minusYears( dateTimeUnit, 1 );
- return createPeriod( dateUnit, calendar );
+ return createPeriod( dateTimeUnit, calendar );
}
/**
* Generates yearly periods for the last 5, current and next 5 years.
*/
@Override
- public List<Period> generatePeriods( DateUnit dateUnit )
+ public List<Period> generatePeriods( DateTimeUnit dateTimeUnit )
{
Calendar cal = getCalendar();
- dateUnit = cal.minusYears( dateUnit, 5 );
- dateUnit.setDay( 1 );
- dateUnit.setMonth( 1 );
+ dateTimeUnit = cal.minusYears( dateTimeUnit, 5 );
+ dateTimeUnit.setDay( 1 );
+ dateTimeUnit.setMonth( 1 );
List<Period> periods = Lists.newArrayList();
for ( int i = 0; i < 11; ++i )
{
- periods.add( createPeriod( dateUnit, cal ) );
- dateUnit = cal.plusYears( dateUnit, 1 );
+ periods.add( createPeriod( dateTimeUnit, cal ) );
+ dateTimeUnit = cal.plusYears( dateTimeUnit, 1 );
}
return periods;
@@ -147,9 +147,9 @@
}
@Override
- public List<Period> generateRollingPeriods( DateUnit dateUnit )
+ public List<Period> generateRollingPeriods( DateTimeUnit dateTimeUnit )
{
- return generateLast5Years( getCalendar().toIso( dateUnit ).toJdkDate() );
+ return generateLast5Years( getCalendar().toIso( dateTimeUnit ).toJdkDate() );
}
/**
@@ -161,26 +161,26 @@
{
Calendar cal = getCalendar();
- DateUnit dateUnit = createLocalDateUnitInstance( date );
- dateUnit = cal.minusYears( dateUnit, 4 );
- dateUnit.setDay( 1 );
- dateUnit.setMonth( 1 );
+ DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( date );
+ dateTimeUnit = cal.minusYears( dateTimeUnit, 4 );
+ dateTimeUnit.setDay( 1 );
+ dateTimeUnit.setMonth( 1 );
List<Period> periods = Lists.newArrayList();
for ( int i = 0; i < 5; ++i )
{
- periods.add( createPeriod( dateUnit, cal ) );
- dateUnit = cal.plusYears( dateUnit, 1 );
+ periods.add( createPeriod( dateTimeUnit, cal ) );
+ dateTimeUnit = cal.plusYears( dateTimeUnit, 1 );
}
return periods;
}
@Override
- public String getIsoDate( DateUnit dateUnit )
+ public String getIsoDate( DateTimeUnit dateTimeUnit )
{
- return String.valueOf( dateUnit.getYear() );
+ return String.valueOf( dateTimeUnit.getYear() );
}
@Override
@@ -197,9 +197,9 @@
date = date != null ? date : new Date();
rewindedPeriods = rewindedPeriods != null ? rewindedPeriods : 1;
- DateUnit dateUnit = createLocalDateUnitInstance( date );
- dateUnit = cal.minusYears( dateUnit, rewindedPeriods );
+ DateTimeUnit dateTimeUnit = createLocalDateUnitInstance( date );
+ dateTimeUnit = cal.minusYears( dateTimeUnit, rewindedPeriods );
- return cal.toIso( dateUnit ).toJdkDate();
+ return cal.toIso( dateTimeUnit ).toJdkDate();
}
}
=== added file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateTimeUnitPeriodTypeParserTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateTimeUnitPeriodTypeParserTest.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateTimeUnitPeriodTypeParserTest.java 2014-08-29 10:02:21 +0000
@@ -0,0 +1,115 @@
+package org.hisp.dhis.calendar;
+
+/*
+ * Copyright (c) 2004-2014, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class DateTimeUnitPeriodTypeParserTest
+{
+ private PeriodTypeParser format;
+
+ @Before
+ public void init()
+ {
+ format = new DateUnitPeriodTypeParser();
+ }
+
+ @Test
+ public void testDateUnitFormatParser()
+ {
+ // daily
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 2, 4 ), new DateTimeUnit( 2014, 2, 4 ) ), format.parse( "20140204" ) );
+
+ // weekly
+ assertEquals( new DateInterval( new DateTimeUnit( 2013, 12, 30 ), new DateTimeUnit( 2014, 1, 5 ) ), format.parse( "2014W1" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 1, 6 ), new DateTimeUnit( 2014, 1, 12 ) ), format.parse( "2014W2" ) );
+
+ // monthly
+ assertNull( format.parse( "2014W0" ) );
+ assertNull( format.parse( "2014W53" ) );
+ assertNotNull( format.parse( "2009W53" ) ); // 2009 has 53 weeks
+ assertNull( format.parse( "2009W54" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 2, 1 ), new DateTimeUnit( 2014, 2, 28 ) ), format.parse( "201402" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 4, 1 ), new DateTimeUnit( 2014, 4, 30 ) ), format.parse( "201404" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 3, 1 ), new DateTimeUnit( 2014, 3, 31 ) ), format.parse( "2014-03" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 5, 1 ), new DateTimeUnit( 2014, 5, 31 ) ), format.parse( "2014-05" ) );
+
+ // bi-monthly
+ assertNull( format.parse( "201400B" ) );
+ assertNull( format.parse( "201407B" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 1, 1 ), new DateTimeUnit( 2014, 2, 28 ) ), format.parse( "201401B" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 3, 1 ), new DateTimeUnit( 2014, 4, 30 ) ), format.parse( "201402B" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 5, 1 ), new DateTimeUnit( 2014, 6, 30 ) ), format.parse( "201403B" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 7, 1 ), new DateTimeUnit( 2014, 8, 31 ) ), format.parse( "201404B" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 9, 1 ), new DateTimeUnit( 2014, 10, 31 ) ), format.parse( "201405B" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 11, 1 ), new DateTimeUnit( 2014, 12, 31 ) ), format.parse( "201406B" ) );
+
+ // quarter
+ assertNull( format.parse( "2014Q0" ) );
+ assertNull( format.parse( "2014Q5" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 1, 1 ), new DateTimeUnit( 2014, 3, 31 ) ), format.parse( "2014Q1" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 4, 1 ), new DateTimeUnit( 2014, 6, 30 ) ), format.parse( "2014Q2" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 7, 1 ), new DateTimeUnit( 2014, 9, 30 ) ), format.parse( "2014Q3" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 10, 1 ), new DateTimeUnit( 2014, 12, 31 ) ), format.parse( "2014Q4" ) );
+
+ // six-monthly
+ assertNull( format.parse( "2014S0" ) );
+ assertNull( format.parse( "2014S3" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 1, 1 ), new DateTimeUnit( 2014, 6, 30 ) ), format.parse( "2014S1" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 7, 1 ), new DateTimeUnit( 2014, 12, 31 ) ), format.parse( "2014S2" ) );
+
+ // six-monthly april
+ assertNull( format.parse( "2014AprilS0" ) );
+ assertNull( format.parse( "2014AprilS3" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 4, 1 ), new DateTimeUnit( 2014, 9, 30 ) ), format.parse( "2014AprilS1" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 10, 1 ), new DateTimeUnit( 2015, 3, 31 ) ), format.parse( "2014AprilS2" ) );
+
+ // yearly
+ assertEquals( new DateInterval( new DateTimeUnit( 2013, 1, 1 ), new DateTimeUnit( 2013, 12, 31 ) ), format.parse( "2013" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 1, 1 ), new DateTimeUnit( 2014, 12, 31 ) ), format.parse( "2014" ) );
+
+ // financial april
+ assertEquals( new DateInterval( new DateTimeUnit( 2013, 4, 1 ), new DateTimeUnit( 2014, 3, 31 ) ), format.parse( "2013April" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 4, 1 ), new DateTimeUnit( 2015, 3, 31 ) ), format.parse( "2014April" ) );
+
+ // financial july
+ assertEquals( new DateInterval( new DateTimeUnit( 2013, 7, 1 ), new DateTimeUnit( 2014, 6, 30 ) ), format.parse( "2013July" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 7, 1 ), new DateTimeUnit( 2015, 6, 30 ) ), format.parse( "2014July" ) );
+
+ // financial october
+ assertEquals( new DateInterval( new DateTimeUnit( 2013, 10, 1 ), new DateTimeUnit( 2014, 9, 30 ) ), format.parse( "2013Oct" ) );
+ assertEquals( new DateInterval( new DateTimeUnit( 2014, 10, 1 ), new DateTimeUnit( 2015, 9, 30 ) ), format.parse( "2014Oct" ) );
+ }
+}
=== added file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateTimeUnitTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateTimeUnitTest.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateTimeUnitTest.java 2014-08-29 10:02:21 +0000
@@ -0,0 +1,110 @@
+package org.hisp.dhis.calendar;
+
+/*
+ * Copyright (c) 2004-2014, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import org.joda.time.DateTime;
+import org.junit.Test;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class DateTimeUnitTest
+{
+ @Test
+ public void fromDateTimeTest()
+ {
+ DateTime dateTime = new DateTime( 2014, 3, 20, 0, 0 );
+ DateTimeUnit dateTimeUnit = DateTimeUnit.fromJodaDateTime( dateTime );
+
+ assertEquals( 2014, dateTimeUnit.getYear() );
+ assertEquals( 3, dateTimeUnit.getMonth() );
+ assertEquals( 20, dateTimeUnit.getDay() );
+ }
+
+ @Test
+ public void fromJdkDateTest()
+ {
+ java.util.Calendar cal = new GregorianCalendar( 2014, 2, 20 );
+ Date date = cal.getTime();
+ DateTimeUnit dateTimeUnit = DateTimeUnit.fromJdkDate( date );
+
+ assertEquals( 2014, dateTimeUnit.getYear() );
+ assertEquals( 3, dateTimeUnit.getMonth() );
+ assertEquals( 20, dateTimeUnit.getDay() );
+ }
+
+ @Test
+ public void fromJdkCalendarTest()
+ {
+ java.util.Calendar cal = new GregorianCalendar( 2014, 2, 20 );
+ DateTimeUnit dateTimeUnit = DateTimeUnit.fromJdkCalendar( cal );
+
+ assertEquals( 2014, dateTimeUnit.getYear() );
+ assertEquals( 3, dateTimeUnit.getMonth() );
+ assertEquals( 20, dateTimeUnit.getDay() );
+ }
+
+ @Test
+ public void toDateTimeTest()
+ {
+ DateTimeUnit dateTimeUnit = new DateTimeUnit( 2014, 3, 20, true );
+ DateTime dateTime = dateTimeUnit.toDateTime();
+
+ assertEquals( 2014, dateTime.getYear() );
+ assertEquals( 3, dateTime.getMonthOfYear() );
+ assertEquals( 20, dateTime.getDayOfMonth() );
+ }
+
+ @Test
+ public void toJdkCalendarTest()
+ {
+ DateTimeUnit dateTimeUnit = new DateTimeUnit( 2014, 3, 20, true );
+ Calendar calendar = dateTimeUnit.toJdkCalendar();
+
+ assertEquals( 2014, calendar.get( Calendar.YEAR ) );
+ assertEquals( 2, calendar.get( Calendar.MONTH ) );
+ assertEquals( 20, calendar.get( Calendar.DAY_OF_MONTH ) );
+ }
+
+ @Test
+ public void toJdkDateTest()
+ {
+ DateTimeUnit dateTimeUnit = new DateTimeUnit( 2014, 3, 20, true );
+
+ assertEquals( 2014, dateTimeUnit.getYear() );
+ assertEquals( 3, dateTimeUnit.getMonth() );
+ assertEquals( 20, dateTimeUnit.getDay() );
+ }
+}
=== removed file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateUnitPeriodTypeParserTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateUnitPeriodTypeParserTest.java 2014-08-11 05:27:09 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateUnitPeriodTypeParserTest.java 1970-01-01 00:00:00 +0000
@@ -1,115 +0,0 @@
-package org.hisp.dhis.calendar;
-
-/*
- * Copyright (c) 2004-2014, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class DateUnitPeriodTypeParserTest
-{
- private PeriodTypeParser format;
-
- @Before
- public void init()
- {
- format = new DateUnitPeriodTypeParser();
- }
-
- @Test
- public void testDateUnitFormatParser()
- {
- // daily
- assertEquals( new DateInterval( new DateUnit( 2014, 2, 4 ), new DateUnit( 2014, 2, 4 ) ), format.parse( "20140204" ) );
-
- // weekly
- assertEquals( new DateInterval( new DateUnit( 2013, 12, 30 ), new DateUnit( 2014, 1, 5 ) ), format.parse( "2014W1" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 1, 6 ), new DateUnit( 2014, 1, 12 ) ), format.parse( "2014W2" ) );
-
- // monthly
- assertNull( format.parse( "2014W0" ) );
- assertNull( format.parse( "2014W53" ) );
- assertNotNull( format.parse( "2009W53" ) ); // 2009 has 53 weeks
- assertNull( format.parse( "2009W54" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 2, 1 ), new DateUnit( 2014, 2, 28 ) ), format.parse( "201402" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 4, 1 ), new DateUnit( 2014, 4, 30 ) ), format.parse( "201404" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 3, 1 ), new DateUnit( 2014, 3, 31 ) ), format.parse( "2014-03" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 5, 1 ), new DateUnit( 2014, 5, 31 ) ), format.parse( "2014-05" ) );
-
- // bi-monthly
- assertNull( format.parse( "201400B" ) );
- assertNull( format.parse( "201407B" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 1, 1 ), new DateUnit( 2014, 2, 28 ) ), format.parse( "201401B" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 3, 1 ), new DateUnit( 2014, 4, 30 ) ), format.parse( "201402B" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 5, 1 ), new DateUnit( 2014, 6, 30 ) ), format.parse( "201403B" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 7, 1 ), new DateUnit( 2014, 8, 31 ) ), format.parse( "201404B" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 9, 1 ), new DateUnit( 2014, 10, 31 ) ), format.parse( "201405B" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 11, 1 ), new DateUnit( 2014, 12, 31 ) ), format.parse( "201406B" ) );
-
- // quarter
- assertNull( format.parse( "2014Q0" ) );
- assertNull( format.parse( "2014Q5" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 1, 1 ), new DateUnit( 2014, 3, 31 ) ), format.parse( "2014Q1" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 4, 1 ), new DateUnit( 2014, 6, 30 ) ), format.parse( "2014Q2" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 7, 1 ), new DateUnit( 2014, 9, 30 ) ), format.parse( "2014Q3" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 10, 1 ), new DateUnit( 2014, 12, 31 ) ), format.parse( "2014Q4" ) );
-
- // six-monthly
- assertNull( format.parse( "2014S0" ) );
- assertNull( format.parse( "2014S3" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 1, 1 ), new DateUnit( 2014, 6, 30 ) ), format.parse( "2014S1" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 7, 1 ), new DateUnit( 2014, 12, 31 ) ), format.parse( "2014S2" ) );
-
- // six-monthly april
- assertNull( format.parse( "2014AprilS0" ) );
- assertNull( format.parse( "2014AprilS3" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 4, 1 ), new DateUnit( 2014, 9, 30 ) ), format.parse( "2014AprilS1" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 10, 1 ), new DateUnit( 2015, 3, 31 ) ), format.parse( "2014AprilS2" ) );
-
- // yearly
- assertEquals( new DateInterval( new DateUnit( 2013, 1, 1 ), new DateUnit( 2013, 12, 31 ) ), format.parse( "2013" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 1, 1 ), new DateUnit( 2014, 12, 31 ) ), format.parse( "2014" ) );
-
- // financial april
- assertEquals( new DateInterval( new DateUnit( 2013, 4, 1 ), new DateUnit( 2014, 3, 31 ) ), format.parse( "2013April" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 4, 1 ), new DateUnit( 2015, 3, 31 ) ), format.parse( "2014April" ) );
-
- // financial july
- assertEquals( new DateInterval( new DateUnit( 2013, 7, 1 ), new DateUnit( 2014, 6, 30 ) ), format.parse( "2013July" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 7, 1 ), new DateUnit( 2015, 6, 30 ) ), format.parse( "2014July" ) );
-
- // financial october
- assertEquals( new DateInterval( new DateUnit( 2013, 10, 1 ), new DateUnit( 2014, 9, 30 ) ), format.parse( "2013Oct" ) );
- assertEquals( new DateInterval( new DateUnit( 2014, 10, 1 ), new DateUnit( 2015, 9, 30 ) ), format.parse( "2014Oct" ) );
- }
-}
=== removed file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateUnitTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateUnitTest.java 2014-06-16 10:42:58 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateUnitTest.java 1970-01-01 00:00:00 +0000
@@ -1,110 +0,0 @@
-package org.hisp.dhis.calendar;
-
-/*
- * Copyright (c) 2004-2014, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-import org.joda.time.DateTime;
-import org.junit.Test;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class DateUnitTest
-{
- @Test
- public void fromDateTimeTest()
- {
- DateTime dateTime = new DateTime( 2014, 3, 20, 0, 0 );
- DateUnit dateUnit = DateUnit.fromDateTime( dateTime );
-
- assertEquals( 2014, dateUnit.getYear() );
- assertEquals( 3, dateUnit.getMonth() );
- assertEquals( 20, dateUnit.getDay() );
- }
-
- @Test
- public void fromJdkDateTest()
- {
- java.util.Calendar cal = new GregorianCalendar( 2014, 2, 20 );
- Date date = cal.getTime();
- DateUnit dateUnit = DateUnit.fromJdkDate( date );
-
- assertEquals( 2014, dateUnit.getYear() );
- assertEquals( 3, dateUnit.getMonth() );
- assertEquals( 20, dateUnit.getDay() );
- }
-
- @Test
- public void fromJdkCalendarTest()
- {
- java.util.Calendar cal = new GregorianCalendar( 2014, 2, 20 );
- DateUnit dateUnit = DateUnit.fromJdkCalendar( cal );
-
- assertEquals( 2014, dateUnit.getYear() );
- assertEquals( 3, dateUnit.getMonth() );
- assertEquals( 20, dateUnit.getDay() );
- }
-
- @Test
- public void toDateTimeTest()
- {
- DateUnit dateUnit = new DateUnit( 2014, 3, 20, true );
- DateTime dateTime = dateUnit.toDateTime();
-
- assertEquals( 2014, dateTime.getYear() );
- assertEquals( 3, dateTime.getMonthOfYear() );
- assertEquals( 20, dateTime.getDayOfMonth() );
- }
-
- @Test
- public void toJdkCalendarTest()
- {
- DateUnit dateUnit = new DateUnit( 2014, 3, 20, true );
- Calendar calendar = dateUnit.toJdkCalendar();
-
- assertEquals( 2014, calendar.get( Calendar.YEAR ) );
- assertEquals( 2, calendar.get( Calendar.MONTH ) );
- assertEquals( 20, calendar.get( Calendar.DAY_OF_MONTH ) );
- }
-
- @Test
- public void toJdkDateTest()
- {
- DateUnit dateUnit = new DateUnit( 2014, 3, 20, true );
-
- assertEquals( 2014, dateUnit.getYear() );
- assertEquals( 3, dateUnit.getMonth() );
- assertEquals( 20, dateUnit.getDay() );
- }
-}
=== removed file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateUnitTypeTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateUnitTypeTest.java 2014-05-20 06:57:41 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/DateUnitTypeTest.java 1970-01-01 00:00:00 +0000
@@ -1,56 +0,0 @@
-package org.hisp.dhis.calendar;
-
-/*
- * Copyright (c) 2004-2014, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class DateUnitTypeTest
-{
- @Test
- public void testDateUnitTypeFind()
- {
- assertEquals( DateUnitType.DAILY, DateUnitType.find( "20140101" ) );
- assertEquals( DateUnitType.WEEKLY, DateUnitType.find( "2014W1" ) );
- assertEquals( DateUnitType.MONTHLY, DateUnitType.find( "201401" ) );
- assertEquals( DateUnitType.MONTHLY, DateUnitType.find( "2014-01" ) );
- assertEquals( DateUnitType.BI_MONTHLY, DateUnitType.find( "201401B" ) );
- assertEquals( DateUnitType.QUARTERLY, DateUnitType.find( "2014Q1" ) );
- assertEquals( DateUnitType.SIX_MONTHLY, DateUnitType.find( "2014S1" ) );
- assertEquals( DateUnitType.SIX_MONTHLY_APRIL, DateUnitType.find( "2014AprilS1" ) );
- assertEquals( DateUnitType.YEARLY, DateUnitType.find( "2014" ) );
- assertEquals( DateUnitType.FINANCIAL_APRIL, DateUnitType.find( "2014April" ) );
- assertEquals( DateUnitType.FINANCIAL_JULY, DateUnitType.find( "2014July" ) );
- assertEquals( DateUnitType.FINANCIAL_OCTOBER, DateUnitType.find( "2014Oct" ) );
- }
-}
=== removed file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/TimeUnitTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/TimeUnitTest.java 2014-05-21 12:58:29 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/TimeUnitTest.java 1970-01-01 00:00:00 +0000
@@ -1,87 +0,0 @@
-package org.hisp.dhis.calendar;
-
-/*
- * Copyright (c) 2004-2014, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.joda.time.DateTime;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.GregorianCalendar;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class TimeUnitTest
-{
- @Test
- public void testFromDateTime()
- {
- TimeUnit timeUnit = TimeUnit.fromDateTime( new DateTime( 2014, 1, 1, 12, 13, 14 ) );
- testHelper( timeUnit, 12, 13, 14 );
-
- timeUnit = TimeUnit.fromDateTime( new DateTime( 2014, 1, 1, 16, 12, 1 ) );
- testHelper( timeUnit, 16, 12, 1 );
-
- timeUnit = TimeUnit.fromDateTime( new DateTime( 2014, 1, 1, 1, 1, 1 ) );
- testHelper( timeUnit, 1, 1, 1 );
- }
-
- @Test
- public void testFromJdkCalendar()
- {
- TimeUnit timeUnit = TimeUnit.fromJdkCalendar( new GregorianCalendar( 2014, 0, 1, 12, 13, 14 ) );
- testHelper( timeUnit, 12, 13, 14 );
-
- timeUnit = TimeUnit.fromJdkCalendar( new GregorianCalendar( 2014, 0, 1, 16, 12, 1 ) );
- testHelper( timeUnit, 16, 12, 1 );
-
- timeUnit = TimeUnit.fromJdkCalendar( new GregorianCalendar( 2014, 0, 1, 1, 1, 1 ) );
- testHelper( timeUnit, 1, 1, 1 );
- }
-
- @Test
- public void testFromJdkDate()
- {
- TimeUnit timeUnit = TimeUnit.fromJdkDate( new GregorianCalendar( 2014, 0, 1, 12, 13, 14 ).getTime() );
- testHelper( timeUnit, 12, 13, 14 );
-
- timeUnit = TimeUnit.fromJdkDate( new GregorianCalendar( 2014, 0, 1, 16, 12, 1 ).getTime() );
- testHelper( timeUnit, 16, 12, 1 );
-
- timeUnit = TimeUnit.fromJdkDate( new GregorianCalendar( 2014, 0, 1, 1, 1, 1 ).getTime() );
- testHelper( timeUnit, 1, 1, 1 );
- }
-
- private void testHelper( TimeUnit timeUnit, int hour, int minutes, int seconds )
- {
- Assert.assertEquals( hour, timeUnit.getHour() );
- Assert.assertEquals( minutes, timeUnit.getMinute() );
- Assert.assertEquals( seconds, timeUnit.getSecond() );
- }
-}
=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/impl/NepaliCalendarTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/impl/NepaliCalendarTest.java 2014-05-21 11:12:07 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/calendar/impl/NepaliCalendarTest.java 2014-08-29 10:02:21 +0000
@@ -29,7 +29,7 @@
*/
import org.hisp.dhis.calendar.Calendar;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -50,14 +50,14 @@
@Test
public void testToIso()
{
- Assert.assertEquals( new DateUnit( 2014, 4, 14, true ), calendar.toIso( new DateUnit( 2071, 1, 1 ) ) );
- Assert.assertEquals( new DateUnit( 2014, 4, 14, true ), calendar.toIso( 2071, 1, 1 ) );
+ Assert.assertEquals( new DateTimeUnit( 2014, 4, 14, true ), calendar.toIso( new DateTimeUnit( 2071, 1, 1 ) ) );
+ Assert.assertEquals( new DateTimeUnit( 2014, 4, 14, true ), calendar.toIso( 2071, 1, 1 ) );
}
@Test
public void testFromIso()
{
- Assert.assertEquals( new DateUnit( 2071, 1, 1, false ), calendar.fromIso( new DateUnit( 2014, 4, 14, true ) ) );
- Assert.assertEquals( new DateUnit( 2071, 1, 1, false ), calendar.fromIso( 2014, 4, 14 ) );
+ Assert.assertEquals( new DateTimeUnit( 2071, 1, 1, false ), calendar.fromIso( new DateTimeUnit( 2014, 4, 14, true ) ) );
+ Assert.assertEquals( new DateTimeUnit( 2071, 1, 1, false ), calendar.fromIso( 2014, 4, 14 ) );
}
}
=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/RelativePeriodTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/RelativePeriodTest.java 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/RelativePeriodTest.java 2014-08-29 10:02:21 +0000
@@ -28,7 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.mock.MockI18nFormat;
import org.junit.Test;
@@ -50,7 +50,7 @@
private static Date getDate( int year, int month, int day )
{
- return new DateUnit( year, month, day, true ).toJdkDate();
+ return new DateTimeUnit( year, month, day, true ).toJdkDate();
}
@Test
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java 2014-08-29 10:02:21 +0000
@@ -30,7 +30,7 @@
import org.apache.commons.lang.StringUtils;
import org.hisp.dhis.analytics.Partitions;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import org.hisp.dhis.common.ListMap;
import org.hisp.dhis.common.NameableObject;
import org.hisp.dhis.period.Cal;
@@ -78,8 +78,8 @@
Partitions partitions = new Partitions();
- int startYear = PeriodType.getCalendar().fromIso( DateUnit.fromJdkDate( period.getStartDate() ) ).getYear();
- int endYear = PeriodType.getCalendar().fromIso( DateUnit.fromJdkDate( period.getEndDate() ) ).getYear();
+ int startYear = PeriodType.getCalendar().fromIso( DateTimeUnit.fromJdkDate( period.getStartDate() ) ).getYear();
+ int endYear = PeriodType.getCalendar().fromIso( DateTimeUnit.fromJdkDate( period.getEndDate() ) ).getYear();
while ( startYear <= endYear )
{
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/AddDataElementCategoryOptionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/AddDataElementCategoryOptionAction.java 2014-06-10 20:46:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/AddDataElementCategoryOptionAction.java 2014-08-29 10:02:21 +0000
@@ -30,7 +30,7 @@
import org.apache.commons.lang.StringUtils;
import org.hisp.dhis.calendar.CalendarService;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import org.hisp.dhis.dataelement.DataElementCategoryOption;
import org.hisp.dhis.dataelement.DataElementCategoryService;
@@ -119,13 +119,13 @@
if ( startDate != null && startDate.trim().length() != 0 )
{
- DateUnit isoStartDate = calendarService.getSystemCalendar().toIso( startDate );
+ DateTimeUnit isoStartDate = calendarService.getSystemCalendar().toIso( startDate );
sDate = isoStartDate.toJdkCalendar().getTime();
}
if ( endDate != null && endDate.trim().length() != 0 )
{
- DateUnit isoEndDate = calendarService.getSystemCalendar().toIso( endDate );
+ DateTimeUnit isoEndDate = calendarService.getSystemCalendar().toIso( endDate );
eDate = isoEndDate.toJdkCalendar().getTime();
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/UpdateDataElementCategoryOptionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/UpdateDataElementCategoryOptionAction.java 2014-06-10 20:46:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/category/UpdateDataElementCategoryOptionAction.java 2014-08-29 10:02:21 +0000
@@ -30,7 +30,7 @@
import org.apache.commons.lang.StringUtils;
import org.hisp.dhis.calendar.CalendarService;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import org.hisp.dhis.dataelement.DataElementCategoryOption;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
@@ -127,13 +127,13 @@
if ( startDate != null && startDate.trim().length() != 0 )
{
- DateUnit isoStartDate = calendarService.getSystemCalendar().toIso( startDate );
+ DateTimeUnit isoStartDate = calendarService.getSystemCalendar().toIso( startDate );
sDate = isoStartDate.toJdkCalendar().getTime();
}
if ( endDate != null && endDate.trim().length() != 0 )
{
- DateUnit isoEndDate = calendarService.getSystemCalendar().toIso( endDate );
+ DateTimeUnit isoEndDate = calendarService.getSystemCalendar().toIso( endDate );
eDate = isoEndDate.toJdkCalendar().getTime();
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java 2014-08-29 10:02:21 +0000
@@ -36,7 +36,7 @@
import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.calendar.CalendarService;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -274,7 +274,7 @@
// Create organisation unit
// ---------------------------------------------------------------------
- DateUnit isoOpeningDate = calendarService.getSystemCalendar().toIso( openingDate );
+ DateTimeUnit isoOpeningDate = calendarService.getSystemCalendar().toIso( openingDate );
OrganisationUnit organisationUnit = new OrganisationUnit( name, shortName, code, isoOpeningDate.toJdkCalendar().getTime(), null, active, comment );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitAction.java 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitAction.java 2014-08-29 10:02:21 +0000
@@ -33,7 +33,7 @@
import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.attribute.comparator.AttributeSortOrderComparator;
import org.hisp.dhis.calendar.CalendarService;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
@@ -211,16 +211,16 @@
if ( organisationUnit.getOpeningDate() != null )
{
- DateUnit dateUnit = DateUnit.fromJdkDate( organisationUnit.getOpeningDate() );
- dateUnit = calendarService.getSystemCalendar().fromIso( dateUnit );
- openingDate = calendarService.getSystemCalendar().formattedDate( dateUnit );
+ DateTimeUnit dateTimeUnit = DateTimeUnit.fromJdkDate( organisationUnit.getOpeningDate() );
+ dateTimeUnit = calendarService.getSystemCalendar().fromIso( dateTimeUnit );
+ openingDate = calendarService.getSystemCalendar().formattedDate( dateTimeUnit );
}
if ( organisationUnit.getClosedDate() != null )
{
- DateUnit dateUnit = DateUnit.fromJdkDate( organisationUnit.getClosedDate() );
- dateUnit = calendarService.getSystemCalendar().fromIso( dateUnit );
- closedDate = calendarService.getSystemCalendar().formattedDate( dateUnit );
+ DateTimeUnit dateTimeUnit = DateTimeUnit.fromJdkDate( organisationUnit.getClosedDate() );
+ dateTimeUnit = calendarService.getSystemCalendar().fromIso( dateTimeUnit );
+ closedDate = calendarService.getSystemCalendar().formattedDate( dateTimeUnit );
}
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/ShowAddOrganisationUnitFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/ShowAddOrganisationUnitFormAction.java 2014-06-06 12:39:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/ShowAddOrganisationUnitFormAction.java 2014-08-29 10:02:21 +0000
@@ -33,7 +33,7 @@
import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.attribute.comparator.AttributeSortOrderComparator;
import org.hisp.dhis.calendar.CalendarService;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
@@ -105,7 +105,7 @@
public String execute()
{
- DateUnit today = calendarService.getSystemCalendar().today();
+ DateTimeUnit today = calendarService.getSystemCalendar().today();
defaultDate = calendarService.getSystemCalendar().formattedDate( today );
dataSets = new ArrayList<>( dataSetService.getAllDataSets() );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java 2014-08-29 10:02:21 +0000
@@ -40,7 +40,7 @@
import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.calendar.CalendarService;
-import org.hisp.dhis.calendar.DateUnit;
+import org.hisp.dhis.calendar.DateTimeUnit;
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
@@ -272,14 +272,14 @@
email = nullIfEmpty( email );
phoneNumber = nullIfEmpty( phoneNumber );
- DateUnit isoOpeningDate = calendarService.getSystemCalendar().toIso( openingDate );
+ DateTimeUnit isoOpeningDate = calendarService.getSystemCalendar().toIso( openingDate );
Date oDate = isoOpeningDate.toJdkCalendar().getTime();
Date cDate = null;
if ( closedDate != null && closedDate.trim().length() != 0 )
{
- DateUnit isoClosingDate = calendarService.getSystemCalendar().toIso( closedDate );
+ DateTimeUnit isoClosingDate = calendarService.getSystemCalendar().toIso( closedDate );
cDate = isoClosingDate.toJdkCalendar().getTime();
}