我有一个从java.util.Date扩展的类。但是,我需要确保条件instanceof Date返回false。这可能吗?原因是因为我需要重写与之集成的框架的功能,如果它的类型为Date,它将改变我的对象的行为。
import java.io.Serializable;
import java.util.Date;
public abstract class KronosDateTime extends Date implements Serializable {
public KronosDateTime(final long time) {
super(time);
}
public KronosDateTime() {
super();
}
public abstract double toDoubleValue();
}
public final class KronosDateTimeImpl extends KronosDateTime {
public KronosDateTimeImpl() {
this(System.currentTimeMillis(),true);
}
}
public final class Kronos {
public static KronosDateTime call(PageContext pc) {
KronosDateTimeImpl dateTime = new KronosDateTimeImpl(pc);
System.out.println(dateTime instanceof java.util.Date); // Should return false
return dateTime;
}
}
慕容708150
相关分类