dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16388
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6224: Impl dateutils method
------------------------------------------------------------
revno: 6224
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-03-08 16:19:22 +0100
message:
Impl dateutils method
modified:
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java 2012-03-08 14:30:26 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java 2012-03-08 15:19:22 +0000
@@ -349,18 +349,31 @@
{
return DateValidator.getInstance().isValid( dateString, DEFAULT_DATE_FORMAT, true );
}
-
+
/**
* Returns the number of seconds until the next day at the given hour.
+ *
* @param hour the hour.
* @return number of seconds.
*/
public static long getSecondsUntilTomorrow( int hour )
{
+ Date date = getDateForTomorrow( hour );
+ return ( date.getTime() - new Date().getTime() ) / MS_PER_S;
+ }
+
+ /**
+ * Returns a date set to tomorrow at the given hour.
+ *
+ * @param hour the hour.
+ * @return a date.
+ */
+ public static Date getDateForTomorrow( int hour )
+ {
Calendar cal = PeriodType.createCalendarInstance();
cal.add( Calendar.DAY_OF_YEAR, 1 );
cal.set( Calendar.HOUR_OF_DAY, hour );
- return ( cal.getTimeInMillis() - new Date().getTime() ) / MS_PER_S;
+ return cal.getTime();
}
/**