Author: rhauch
Date: 2008-07-15 17:17:01 -0400 (Tue, 15 Jul 2008)
New Revision: 357
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/DateTimeFactory.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java
Log:
DNA-115 - Create federation service
http://jira.jboss.com/jira/browse/DNA-115
Added a method to the DateTimeFactory to create a DateTime representing the current time
in UTC. There was already a method to create an instance representing the current time,
but this new method allows for a more efficient implementation.
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/DateTimeFactory.java
===================================================================
--- trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/DateTimeFactory.java 2008-07-14
20:34:33 UTC (rev 356)
+++ trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/DateTimeFactory.java 2008-07-15
21:17:01 UTC (rev 357)
@@ -24,8 +24,7 @@
/**
* A factory for creating {@link DateTime date-time instants}. This interface extends the
{@link ValueFactory} generic interface
* and adds specific methods for creating instants for the current time (and time zone)
as well as various combinations of
- * individual field values.
- * <h2>ISO-8601</h2>
+ * individual field values. <h2>ISO-8601</h2>
* <p>
* The factory creates date-time instants from strings that are in the standard ISO-8601
format. There are three supported styles:
* month-based, day-of-year-based, and week-based.
@@ -96,18 +95,30 @@
* the previous year, and the last week finishes in the next year. The weekyear field is
defined to refer to the year that owns
* the week, which may differ from the actual year.
* </p>
+ *
* @author Randall Hauch
*/
public interface DateTimeFactory extends ValueFactory<DateTime> {
/**
- * Create a date-time instance for the current time.
- * @return the date-time instance
+ * Create a date-time instance for the current time in the local time zone.
+ *
+ * @return the current date-time instance
+ * @see #createUtc()
*/
DateTime create();
/**
+ * Create a date-time instance for the current time in UTC.
+ *
+ * @return the current date-time instance (in UTC)
+ * @see #create()
+ */
+ DateTime createUtc();
+
+ /**
* Create a date-time instance given the individual values for the fields
+ *
* @param year the year of the era
* @param monthOfYear the month of the year
* @param dayOfMonth the day of the month
@@ -117,10 +128,17 @@
* @param millisecondsOfSecond the milliseconds of the second
* @return the date-time instance
*/
- DateTime create( int year, int monthOfYear, int dayOfMonth, int hourOfDay, int
minuteOfHour, int secondOfMinute, int millisecondsOfSecond );
+ DateTime create( int year,
+ int monthOfYear,
+ int dayOfMonth,
+ int hourOfDay,
+ int minuteOfHour,
+ int secondOfMinute,
+ int millisecondsOfSecond );
/**
* Create a date-time instance given the individual values for the fields
+ *
* @param year the year of the era
* @param monthOfYear the month of the year
* @param dayOfMonth the day of the month
@@ -131,10 +149,18 @@
* @param timeZoneOffsetHours the number of hours offset from UTC for the time zone
* @return the date-time instance
*/
- DateTime create( int year, int monthOfYear, int dayOfMonth, int hourOfDay, int
minuteOfHour, int secondOfMinute, int millisecondsOfSecond, int timeZoneOffsetHours );
+ DateTime create( int year,
+ int monthOfYear,
+ int dayOfMonth,
+ int hourOfDay,
+ int minuteOfHour,
+ int secondOfMinute,
+ int millisecondsOfSecond,
+ int timeZoneOffsetHours );
/**
* Create a date-time instance given the individual values for the fields
+ *
* @param year the year of the era
* @param monthOfYear the month of the year
* @param dayOfMonth the day of the month
@@ -145,6 +171,13 @@
* @param timeZoneId the ID of the time zone (e.g, "PST", "UTC",
"EDT"); may not be null
* @return the date-time instance
*/
- DateTime create( int year, int monthOfYear, int dayOfMonth, int hourOfDay, int
minuteOfHour, int secondOfMinute, int millisecondsOfSecond, String timeZoneId );
+ DateTime create( int year,
+ int monthOfYear,
+ int dayOfMonth,
+ int hourOfDay,
+ int minuteOfHour,
+ int secondOfMinute,
+ int millisecondsOfSecond,
+ String timeZoneId );
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java 2008-07-14
20:34:33 UTC (rev 356)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/JodaDateTimeValueFactory.java 2008-07-15
21:17:01 UTC (rev 357)
@@ -37,6 +37,7 @@
import org.jboss.dna.spi.graph.PropertyType;
import org.jboss.dna.spi.graph.Reference;
import org.jboss.dna.spi.graph.ValueFactory;
+import org.joda.time.DateTimeZone;
/**
* The standard {@link ValueFactory} for {@link PropertyType#DATE} values.
@@ -207,7 +208,16 @@
/**
* {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.graph.DateTimeFactory#createUtc()
*/
+ public DateTime createUtc() {
+ return new JodaDateTime(DateTimeZone.UTC);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public DateTime create( int year,
int monthOfYear,
int dayOfMonth,