⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datadaterange.java

📁 一个用java写的地震分析软件(无源码)-used to write a seismic analysis software (without source)
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package org.trinet.jdbc.datatypes;
import java.util.*;
import org.trinet.jdbc.*;
import org.trinet.jdbc.datatypes.*;
import org.trinet.util.*;

/** Class implements a DataDate range. */
public class DataDateRange extends DataObjectRange implements DateStringFormatter, ValueParser, Cloneable, Comparable {

    protected String dateFormat = "yyyy-MM-dd:HH:mm:ss.SSS";

/** Default constructor, isNull() == true. */
    public DataDateRange() {
        this(new DataDate(), new DataDate());
    }

/** Constructor creates minimum and maximum bounds from the input object values.
* @exception java.lang.NullPointerException     input Date parameter min == null || max == null 
* @exception java.lang.IllegalArgumentException max < min
*/
    public DataDateRange(DataDate  min, DataDate max) {
        super(min, max);
    }

/** Constructor creates minimum and maximum bounds from the input object values.
* @exception java.lang.NullPointerException     input Date parameter min == null || max == null 
* @exception java.lang.IllegalArgumentException max < min
*/
    public DataDateRange(java.util.Date  min, java.util.Date max) {
        this(new DataDate(min), new DataDate(max));
    }

/** Constructor uses EpochTime.epochToDate(double) to construct date bounds. */
    public DataDateRange(double minEpoch, double maxEpoch) {
        this(EpochTime.epochToDate(minEpoch), EpochTime.epochToDate(maxEpoch));
    }

/** Constructor uses EpochTime.stringToDate(String date, String pattern) to construct date bounds. */
    public DataDateRange(String minDate, String maxDate, String pattern ) {
        this(EpochTime.stringToDate(minDate, pattern), EpochTime.stringToDate(maxDate, pattern)); 
        this.dateFormat = pattern;
    }

/** Returns milliseconds value of lower bound. */
    protected long getMinTime() {
        return min.longValue();
    }

/** Returns milliseconds value of upper bound. */
    protected long getMaxTime() {
        return max.longValue(); }

/** Returns a clone of the minimum bound. */
    public java.util.Date getMinValue() {
        return ((DataDate) min).dateValue();
    }

/** Returns a clone of the maximum bound. */
    public java.util.Date getMaxValue() {
        return ((DataDate) max).dateValue();
    }

/** Returns the size of the range as a double seconds. */
    public double seconds() {
        return doubleExtent()/1000.;
    }

/** Returns the size of the range as a double milliseconds. */
    public double doubleExtent() {
        return (double) (max.longValue() - min.longValue());
    }

/** Returns the size of the range as a long milliseconds. */
    public long longExtent() {
        return max.longValue() - min.longValue();
    }

/** True if minimum bound of this instance is after the input date. */
    public boolean after(java.util.Date date) {
        return ((DataDate) min).value.after(date);
    }

/** True if minimum bound of this instance is after the maximum bound of the input range. */
    public boolean after(DataDateRange range) {
        return after(range.max); 
    }

/** True if maximum bound of this instance is before the input date. */
    public boolean before(java.util.Date date) {
        return ((DataDate) max).value.before(date);
    }

/** True if maximum bound of this instance is before than mininum bound of input range. */
    public boolean before(DataDateRange range) {
        return before(range.min); 
    }

/** True if this object's range excludes input date. */
    public boolean excludes(java.util.Date date) {
        return ! contains(date);
    }

/** True if this object's range excludes input object's range. */
    public boolean excludes(DataDateRange range) {
        return ! overlaps(range.min, range.max);
    }

/** True if this object's range excludes input range. */
    public boolean excludes(java.util.Date minDate, java.util.Date maxDate) {
        return ! overlaps(minDate, maxDate);
    }

/** True if this object's range contains input object's range. */
    public boolean contains(DataDateRange range) {
        return contains(range.min, range.max); 
    }

/** True if this object's range contains input range. */
    public boolean contains(java.util.Date minDate, java.util.Date maxDate) {
        return ( contains(minDate) && contains(maxDate) );
    }

/** True if this object's range contains input date. */
    public boolean contains(java.util.Date date) {
        return ! ( after(date) || before(date) );
    }

/** True if this object's range overlaps input object's range. */
    public boolean overlaps(DataDateRange range) {
        return overlaps(range.min, range.max);
    }

/** True if this object's range overlaps input range. */
    public boolean overlaps(java.util.Date minDate, java.util.Date maxDate) {
        return ! ( minDate.after(((DataDate) max).value) || maxDate.before(((DataDate) min).value) );
    }

/** True if this object's range lies within input object's range. */
    public boolean within(DataDateRange range) {
        return range.contains(this); 
    }

/** True if this object's range lies within input range. */
    public boolean within(java.util.Date minDate, java.util.Date maxDate) {
        return ! ( ((DataDate) min).value.before(minDate) || ((DataDate) max).value.after(maxDate) );
    }

/** Returns true only if the input object is an instance of DataDateRange and
* its minimum and maximum values are equivalent to this object's values.
*/
    public boolean equals(Object object) {
        if (this == object) return true;
        if (object == null || ! (getClass() != object.getClass()) ) return false;
        DataDateRange range = (DataDateRange) object;
        return (min.equals(range.min) && max.equals(range.max));
    }

/** Returns true only if the input range's minimum and maximum values
* are equivalent to this object's values.
*/
    public boolean equalsRange(DataDateRange range) {
        if (this == range) return true;
        if (range == null) return false;
        return (min.equalsValue(range.min) && max.equalsValue(range.max));
    }

/** Input object must in an instance of DataDateRange. 
* @return <pre>
* -1 this object's minimum value is less than the input object's value,
*    or it is equivalent and this object's maximum value is less than the input object's value.<br>
*  0 this object's minimum and maximum values are equivalent to the input object's values.<br>
*  1 this object's minimum value is greater than the input object's value,
*    or it is equivalent and its maximum value is greater than the input object's value.
* </pre>
* @exception java.lang.NullPointerException input object is null
* @exception java.lang.ClassCastException input object is not an instance of DataDateRange.
*/
    public int compareTo(Object object) {
        DataDateRange range = (DataDateRange) object;
        int retVal = min.compareTo(range.min);
        if (retVal != 0) return retVal;
        return (max.compareTo(range.max) < 0 ) ? -1 : 1;
    }

/** Returns true if max < min. */
    public boolean isReversed() {
        return ( ((DataDate) min).compareTo(max) > 0);
    }

/** Returns false if (isReversed() || min == null || max == null). */
    public boolean isValid() {
        return (min != null && max != null) ? isReversed() : false;
    }

/** Returns String concatenation of minimum and maximum bounds values 
* formatted as specified by the input pattern relative to UTC time zone.
* The min, max dates are separated by " ".
*/
    public String toDateString(String pattern) {
        StringBuffer sb = new StringBuffer(80);
        sb.append(EpochTime.dateToString( ((DataDate) min).value, pattern) );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -