You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/10/15 15:42:42 UTC
svn commit: r825495 - in /incubator/pivot/trunk:
core/src/org/apache/pivot/util/CalendarDate.java
wtk/src/org/apache/pivot/wtk/content/TableViewDateCellRenderer.java
Author: gbrown
Date: Thu Oct 15 13:42:41 2009
New Revision: 825495
URL: http://svn.apache.org/viewvc?rev=825495&view=rev
Log:
Remove getTime() from CalendarDate (this method was not appropriate for this class).
Modified:
incubator/pivot/trunk/core/src/org/apache/pivot/util/CalendarDate.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewDateCellRenderer.java
Modified: incubator/pivot/trunk/core/src/org/apache/pivot/util/CalendarDate.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/src/org/apache/pivot/util/CalendarDate.java?rev=825495&r1=825494&r2=825495&view=diff
==============================================================================
--- incubator/pivot/trunk/core/src/org/apache/pivot/util/CalendarDate.java (original)
+++ incubator/pivot/trunk/core/src/org/apache/pivot/util/CalendarDate.java Thu Oct 15 13:42:41 2009
@@ -46,8 +46,6 @@
*/
public final int day;
- private long time = -1;
-
private static final int[] MONTH_LENGTHS = {
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
@@ -185,25 +183,13 @@
* <tt>calendarDate</tt>.
*/
public int subtract(CalendarDate calendarDate) {
- long t1 = getTime();
- long t2 = calendarDate.getTime();
+ GregorianCalendar c1 = toCalendar();
+ GregorianCalendar c2 = calendarDate.toCalendar();
- return (int)((t1 - t2) / (1000l * 60 * 60 * 24));
- }
-
- /**
- * Returns this calendar date as a millisecond value. The value is the
- * number of milliseconds since midnight GMT on January 1, 1970.
- *
- * @return
- * The number of milliseconds since midnight GMT on January 1, 1970.
- */
- public long getTime() {
- if (time == -1) {
- time = toCalendar().getTimeInMillis();
- }
+ long t1 = c1.getTimeInMillis();
+ long t2 = c2.getTimeInMillis();
- return time;
+ return (int)((t1 - t2) / (1000l * 60 * 60 * 24));
}
/**
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewDateCellRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewDateCellRenderer.java?rev=825495&r1=825494&r2=825495&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewDateCellRenderer.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewDateCellRenderer.java Thu Oct 15 13:42:41 2009
@@ -81,7 +81,7 @@
} else if (cellData instanceof Calendar) {
formattedDate = dateFormat.format(((Calendar)cellData).getTime());
} else if (cellData instanceof CalendarDate) {
- formattedDate = dateFormat.format(new Date(((CalendarDate)cellData).getTime()));
+ formattedDate = dateFormat.format(((CalendarDate)cellData).toCalendar().getTime());
} else {
System.err.println(getClass().getName() + " cannot render " + cellData);
}