Author: michiel
Date: 2009-05-02 08:55:49 +0200 (Sat, 02 May 2009)
New Revision: 34905
Modified:
mmbase/trunk/src/org/mmbase/util/DynamicDate.java
Log:
Added @Override's and an extra command line argument (the format)
Modified: mmbase/trunk/src/org/mmbase/util/DynamicDate.java
===================================================================
--- mmbase/trunk/src/org/mmbase/util/DynamicDate.java 2009-05-02 06:23:54 UTC
(rev 34904)
+++ mmbase/trunk/src/org/mmbase/util/DynamicDate.java 2009-05-02 06:55:49 UTC
(rev 34905)
@@ -41,7 +41,7 @@
*/
public class DynamicDate extends Date {
-
+ private final static long serialVersionUID = 0L;
/**
* Parses a format string and returns Date instance, possibly a 'dynamic
one'. Not necessary a new one, which
* does not matter, because these objects are unmodifiable anyway.
@@ -125,14 +125,17 @@
// all methods of Date itself are simply wrapped..
+ @Override
public boolean after(Date when) {
return evalDate().after(when);
}
+ @Override
public boolean before(Date when) {
return evalDate().before(when);
}
+ @Override
public Object clone() {
try {
return getInstance(date);
@@ -140,10 +143,12 @@
return new Date();
}
}
+ @Override
public int compareTo(Date anotherDate) {
return evalDate().compareTo(anotherDate);
}
+ @Override
public boolean equals(Object obj) {
if (obj instanceof DynamicDate) {
return date.equals(((DynamicDate)obj).date);
@@ -151,66 +156,86 @@
return false;
}
}
- @Deprecated public int getDate() {
+ @depreca...@override
+ public int getDate() {
return evalDate().getDate();
}
- @Deprecated public int getDay() {
+ @depreca...@override
+ public int getDay() {
return evalDate().getDay();
}
- @Deprecated public int getHours() {
+ @depreca...@override
+ public int getHours() {
return evalDate().getHours();
}
- @Deprecated public int getMinutes() {
+ @depreca...@override
+ public int getMinutes() {
return evalDate().getMinutes();
}
- @Deprecated public int getMonth() {
+ @depreca...@override
+ public int getMonth() {
return evalDate().getMonth();
}
- @Deprecated public int getSeconds() {
+ @depreca...@override
+ public int getSeconds() {
return evalDate().getSeconds();
}
+ @Override
public long getTime() {
return evalDate().getTime();
}
- @Deprecated public int getTimezoneOffset() {
+ @depreca...@override
+ public int getTimezoneOffset() {
return evalDate().getTimezoneOffset();
}
- @Deprecated public int getYear() {
+ @depreca...@override
+ public int getYear() {
return evalDate().getYear();
}
+ @Override
public int hashCode() {
return date.hashCode();
}
- @Deprecated public void setDate(int date) {
+ @depreca...@override
+ public void setDate(int date) {
throw new UnsupportedOperationException("Cannot set date in dynamic
date");
}
- @Deprecated public void setHours(int hours) {
+ @depreca...@override
+ public void setHours(int hours) {
throw new UnsupportedOperationException("Cannot set date in dynamic
date");
}
- @Deprecated public void setMinutes(int minutes) {
+ @depreca...@override
+ public void setMinutes(int minutes) {
throw new UnsupportedOperationException("Cannot set date in dynamic
date");
}
- @Deprecated public void setMonth(int month) {
+ @depreca...@override
+ public void setMonth(int month) {
throw new UnsupportedOperationException("Cannot set date in dynamic
date");
}
- @Deprecated public void setSeconds(int seconds) {
+ @depreca...@override
+ public void setSeconds(int seconds) {
throw new UnsupportedOperationException("Cannot set date in dynamic
date");
}
- @Deprecated public void setTime(long time) {
+ @depreca...@override
+ public void setTime(long time) {
throw new UnsupportedOperationException("Cannot set date in dynamic
date");
}
- @Deprecated public void setYear(int year) {
+ @depreca...@override
+ public void setYear(int year) {
throw new UnsupportedOperationException("Cannot set date in dynamic
date");
}
- @Deprecated public String toGMTString() {
+ @depreca...@override
+ public String toGMTString() {
return evalDate().toGMTString();
}
- @Deprecated public String toLocaleString() {
+ @depreca...@override
+ public String toLocaleString() {
return evalDate().toLocaleString();
}
+ @Override
public String toString() {
return date + ": " + evalDate().toString();
}
@@ -262,9 +287,15 @@
System.out.println("Also try with different values for
-Duser.timezone=");
} else {
Date d1 = getInstance(argv[0]);
+ if (argv.length > 1) {
+ java.text.DateFormat my = new
java.text.SimpleDateFormat(argv[1]);
+ System.out.println(my.format(d1));
+ } else {
+ System.out.println(formatter.format(d1) + " " + d1.getTime());
+ }
//Date d2 = Casting.ISO_8601_UTC.parse(argv[0]);
//Date d3 = new Date(Long.MIN_VALUE);
- System.out.println(formatter.format(d1) + " " + d1.getTime());
+
//System.out.println("" + d2 + " " + d2.getTime());
//System.out.println("" + d3 + " " + d3.getTime());
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs