[DS-610] Check granularity before returning DCDate as a java.util.Date.

git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5159 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Robin Taylor
2010-06-29 19:57:34 +00:00
parent 8a7f3acfe3
commit 9b856653df

View File

@@ -287,18 +287,17 @@ public class DCDate
} }
/** /**
* Get the date as a Java Date object * Get the date as a Java Date object, assuming the granularity is sufficient for it to be expressed as a Date.
* *
* @return a Date object * @return a Date object
*/ */
public Date toDate() public Date toDate()
{ {
if (calendar == null) if ((calendar == null) || (!withinGranularity(DateGran.DAY)))
return null; return null;
else else
return calendar.getTime(); return calendar.getTime();
} }
/** /**
* Set the date. The date passed in is assumed to be in the current time * Set the date. The date passed in is assumed to be in the current time
* zone, and is adjusting to fit the current time zone. Unknown values * zone, and is adjusting to fit the current time zone. Unknown values
@@ -317,6 +316,7 @@ public class DCDate
* @param ss * @param ss
* the seconds * the seconds
*/ */
public void setDateLocal(int yyyy, int mm, int dd, int hh, int mn, int ss) public void setDateLocal(int yyyy, int mm, int dd, int hh, int mn, int ss)
{ {
// default values // default values