Example usage for org.joda.time DateTimeConstants MILLIS_PER_DAY

List of usage examples for org.joda.time DateTimeConstants MILLIS_PER_DAY

Introduction

In this page you can find the example usage for org.joda.time DateTimeConstants MILLIS_PER_DAY.

Prototype

int MILLIS_PER_DAY

To view the source code for org.joda.time DateTimeConstants MILLIS_PER_DAY.

Click Source Link

Document

Milliseconds in a typical day (ISO).

Usage

From source file:com.music.service.text.TimelineToMusicService.java

License:Open Source License

/**
 * Gets the tempo, depending on the rate of tweeting
 *
 * @param tweets/*ww w. java 2 s. c  o  m*/
 * @return tempo
 */
private Tempo getTempo(List<Tweet> tweets, TimelineMusic meta) {
    long totalSpacingInMillis = 0;
    Tweet previousTweet = null;
    for (Tweet tweet : tweets) {
        if (previousTweet != null) {
            totalSpacingInMillis += Math
                    .abs(previousTweet.getCreatedAt().getTime() - tweet.getCreatedAt().getTime());
        }
        previousTweet = tweet;
    }

    double averageSpacing = totalSpacingInMillis / (tweets.size() - 1);
    meta.setAverageSpacing(averageSpacing);

    if (averageSpacing > 3 * DateTimeConstants.MILLIS_PER_DAY) { //once every three days
        return Tempo.VERY_SLOW;
    } else if (averageSpacing > 1.5 * DateTimeConstants.MILLIS_PER_DAY) { // more than once every 1.5 days
        return Tempo.SLOW;
    } else if (averageSpacing > 16 * DateTimeConstants.MILLIS_PER_HOUR) { // more than once every 16 hours
        return Tempo.MEDIUM;
    } else if (averageSpacing > 4 * DateTimeConstants.MILLIS_PER_HOUR) { // more than once every 4 hours
        return Tempo.FAST;
    } else {
        return Tempo.VERY_FAST;
    }
}

From source file:influent.server.utilities.ConstrainedDateRange.java

License:MIT License

/**
 * Constructs a date range that is constrained to begin and end on instances of the specified
 * interval, and that is guaranteed to include the range specified.
 * /*from   w w  w  .  j  ava  2 s. co m*/
 * @param start
 * @param interval
 * @param numBins
 */
public ConstrainedDateRange(DateTime start, FL_DateInterval interval, long numBins) {
    super(start.getMillis(), interval, numBins);

    DateTime constrained = start;

    // constrain to start of interval.
    switch (interval) {

    case SECONDS:
        constrained = new DateTime(start.getYear(), start.getMonthOfYear(), start.getDayOfMonth(),
                start.getHourOfDay(), start.getMinuteOfHour(), start.getSecondOfMinute(), DateTimeZone.UTC);
        break;

    case HOURS:
        constrained = new DateTime(start.getYear(), start.getMonthOfYear(), start.getDayOfMonth(),
                start.getHourOfDay(), 0, DateTimeZone.UTC);
        break;

    case DAYS:
        constrained = new DateTime(start.getYear(), start.getMonthOfYear(), start.getDayOfMonth(), 0, 0,
                DateTimeZone.UTC);
        break;

    case WEEKS:
        constrained = new DateTime(start.getYear(), start.getMonthOfYear(), start.getDayOfMonth(), 0, 0,
                DateTimeZone.UTC);

        final int days = start.getDayOfWeek() % 7;
        final long rewindMillis = days * DateTimeConstants.MILLIS_PER_DAY;

        constrained = new DateTime(constrained.getMillis() - rewindMillis, constrained.getZone());

        break;

    case MONTHS:
        constrained = new DateTime(start.getYear(), start.getMonthOfYear(), 1, 0, 0, DateTimeZone.UTC);
        break;

    case QUARTERS:
        constrained = new DateTime(start.getYear(), 1 + 3 * ((start.getMonthOfYear() - 1) / 3), 1, 0, 0,
                DateTimeZone.UTC);
        break;

    case YEARS:
        constrained = new DateTime(start.getYear(), start.getMonthOfYear(), 1, 0, 0, DateTimeZone.UTC);
        break;
    }

    // add an extra partial interval at the end when not large enough.
    if (!start.equals(constrained)) {
        //System.out.println(start + " -> " + constrained);

        setStartDate(constrained.getMillis());
        setNumBins(numBins + 1);
    }
}

From source file:influent.server.utilities.DateTimeParser.java

License:MIT License

/**
 * @see http://joda-time.sourceforge.net/apidocs/org/joda/time/Period.html#normalizedStandard()
 *///from w  ww  .j a  v  a 2 s .  c o  m
public static Period normalize(Period period) {
    long millis = period.getMillis();
    millis += period.getSeconds() * DateTimeConstants.MILLIS_PER_SECOND;
    millis += period.getMinutes() * DateTimeConstants.MILLIS_PER_MINUTE;
    millis += period.getHours() * DateTimeConstants.MILLIS_PER_HOUR;
    millis += period.getDays() * DateTimeConstants.MILLIS_PER_DAY;
    millis += period.getWeeks() * DateTimeConstants.MILLIS_PER_WEEK;

    Period result = new Period(millis, DateTimeUtils.getPeriodType(PeriodType.standard()),
            ISOChronology.getInstanceUTC());
    int years = period.getYears();
    int months = period.getMonths();

    if (years != 0 || months != 0) {
        years = FieldUtils.safeAdd(years, months / 12);
        months = months % 12;
        if (years != 0) {
            result = result.withYears(years);
        }
        if (months != 0) {
            result = result.withMonths(months);
        }
    }

    return result;
}

From source file:org.apache.drill.exec.planner.common.DrillValuesRelBase.java

License:Apache License

private static void writeLiteral(RexLiteral literal, JsonOutput out) throws IOException {
    switch (literal.getType().getSqlTypeName()) {
    case BIGINT:/*w  w w .j a v  a 2 s  . co m*/
        if (isLiteralNull(literal)) {
            out.writeBigIntNull();
        } else {
            out.writeBigInt(
                    (((BigDecimal) literal.getValue()).setScale(0, BigDecimal.ROUND_HALF_UP)).longValue());
        }
        return;

    case BOOLEAN:
        if (isLiteralNull(literal)) {
            out.writeBooleanNull();
        } else {
            out.writeBoolean((Boolean) literal.getValue());
        }
        return;

    case CHAR:
        if (isLiteralNull(literal)) {
            out.writeVarcharNull();
        } else {
            // Since Calcite treats string literals as fixed char and adds trailing spaces to the strings to make them the
            // same length, here we do an rtrim() to get the string without the trailing spaces. If we don't rtrim, the comparison
            // with Drill's varchar column values would not return a match.
            // TODO: However, note that if the user had explicitly added spaces in the string literals then even those would get
            // trimmed, so this exposes another issue that needs to be resolved.
            out.writeVarChar(((NlsString) literal.getValue()).rtrim().getValue());
        }
        return;

    case DOUBLE:
        if (isLiteralNull(literal)) {
            out.writeDoubleNull();
        } else {
            out.writeDouble(((BigDecimal) literal.getValue()).doubleValue());
        }
        return;

    case FLOAT:
        if (isLiteralNull(literal)) {
            out.writeFloatNull();
        } else {
            out.writeFloat(((BigDecimal) literal.getValue()).floatValue());
        }
        return;

    case INTEGER:
        if (isLiteralNull(literal)) {
            out.writeIntNull();
        } else {
            out.writeInt((((BigDecimal) literal.getValue()).setScale(0, BigDecimal.ROUND_HALF_UP)).intValue());
        }
        return;

    case DECIMAL:
        // Converting exact decimal into double since values in the list may have different scales
        // so the resulting scale wouldn't be calculated correctly
        if (isLiteralNull(literal)) {
            out.writeDoubleNull();
        } else {
            out.writeDouble(((BigDecimal) literal.getValue()).doubleValue());
        }
        return;

    case VARCHAR:
        if (isLiteralNull(literal)) {
            out.writeVarcharNull();
        } else {
            out.writeVarChar(((NlsString) literal.getValue()).getValue());
        }
        return;

    case SYMBOL:
        if (isLiteralNull(literal)) {
            out.writeVarcharNull();
        } else {
            out.writeVarChar(literal.getValue().toString());
        }
        return;

    case DATE:
        if (isLiteralNull(literal)) {
            out.writeDateNull();
        } else {
            out.writeDate(
                    LocalDateTime.ofInstant(Instant.ofEpochMilli(new DateTime(literal.getValue()).getMillis()),
                            ZoneOffset.UTC).toLocalDate());
        }
        return;

    case TIME:
        if (isLiteralNull(literal)) {
            out.writeTimeNull();
        } else {
            out.writeTime(
                    LocalDateTime.ofInstant(Instant.ofEpochMilli(new DateTime(literal.getValue()).getMillis()),
                            ZoneOffset.UTC).toLocalTime());
        }
        return;

    case TIMESTAMP:
        if (isLiteralNull(literal)) {
            out.writeTimestampNull();
        } else {
            out.writeTimestamp(LocalDateTime.ofInstant(
                    Instant.ofEpochMilli(new DateTime(literal.getValue()).getMillis()), ZoneOffset.UTC));
        }
        return;

    case INTERVAL_YEAR:
    case INTERVAL_YEAR_MONTH:
    case INTERVAL_MONTH:
        if (isLiteralNull(literal)) {
            out.writeIntervalNull();
        } else {
            int months = ((BigDecimal) (literal.getValue())).intValue();
            out.writeInterval(new Period().plusMonths(months));
        }
        return;

    case INTERVAL_DAY:
    case INTERVAL_DAY_HOUR:
    case INTERVAL_DAY_MINUTE:
    case INTERVAL_DAY_SECOND:
    case INTERVAL_HOUR:
    case INTERVAL_HOUR_MINUTE:
    case INTERVAL_HOUR_SECOND:
    case INTERVAL_MINUTE:
    case INTERVAL_MINUTE_SECOND:
    case INTERVAL_SECOND:
        if (isLiteralNull(literal)) {
            out.writeIntervalNull();
        } else {
            long millis = ((BigDecimal) (literal.getValue())).longValue();
            int days = (int) (millis / DateTimeConstants.MILLIS_PER_DAY);
            millis = millis - (days * DateTimeConstants.MILLIS_PER_DAY);
            out.writeInterval(new Period().plusDays(days).plusMillis((int) millis));
        }
        return;

    case NULL:
        out.writeUntypedNull();
        return;

    case ANY:
    default:
        throw new UnsupportedOperationException(
                String.format("Unable to convert the value of %s and type %s to a Drill constant expression.",
                        literal, literal.getType().getSqlTypeName()));
    }
}

From source file:org.apache.drill.exec.planner.ParquetPartitionDescriptor.java

License:Apache License

private void populatePruningVector(ValueVector v, int index, SchemaPath column, Path file) {
    Path path = Path.getPathWithoutSchemeAndAuthority(file);
    TypeProtos.MajorType majorType = getVectorType(column, null);
    TypeProtos.MinorType type = majorType.getMinorType();
    switch (type) {
    case BIT: {// ww  w  . jav a 2s . c  o  m
        NullableBitVector bitVector = (NullableBitVector) v;
        Boolean value = groupScan.getPartitionValue(path, column, Boolean.class);
        if (value == null) {
            bitVector.getMutator().setNull(index);
        } else {
            bitVector.getMutator().setSafe(index, value ? 1 : 0);
        }
        return;
    }
    case INT: {
        NullableIntVector intVector = (NullableIntVector) v;
        Integer value = groupScan.getPartitionValue(path, column, Integer.class);
        if (value == null) {
            intVector.getMutator().setNull(index);
        } else {
            intVector.getMutator().setSafe(index, value);
        }
        return;
    }
    case SMALLINT: {
        NullableSmallIntVector smallIntVector = (NullableSmallIntVector) v;
        Integer value = groupScan.getPartitionValue(path, column, Integer.class);
        if (value == null) {
            smallIntVector.getMutator().setNull(index);
        } else {
            smallIntVector.getMutator().setSafe(index, value.shortValue());
        }
        return;
    }
    case TINYINT: {
        NullableTinyIntVector tinyIntVector = (NullableTinyIntVector) v;
        Integer value = groupScan.getPartitionValue(path, column, Integer.class);
        if (value == null) {
            tinyIntVector.getMutator().setNull(index);
        } else {
            tinyIntVector.getMutator().setSafe(index, value.byteValue());
        }
        return;
    }
    case UINT1: {
        NullableUInt1Vector intVector = (NullableUInt1Vector) v;
        Integer value = groupScan.getPartitionValue(path, column, Integer.class);
        if (value == null) {
            intVector.getMutator().setNull(index);
        } else {
            intVector.getMutator().setSafe(index, value.byteValue());
        }
        return;
    }
    case UINT2: {
        NullableUInt2Vector intVector = (NullableUInt2Vector) v;
        Integer value = groupScan.getPartitionValue(path, column, Integer.class);
        if (value == null) {
            intVector.getMutator().setNull(index);
        } else {
            intVector.getMutator().setSafe(index, (char) value.shortValue());
        }
        return;
    }
    case UINT4: {
        NullableUInt4Vector intVector = (NullableUInt4Vector) v;
        Integer value = groupScan.getPartitionValue(path, column, Integer.class);
        if (value == null) {
            intVector.getMutator().setNull(index);
        } else {
            intVector.getMutator().setSafe(index, value);
        }
        return;
    }
    case BIGINT: {
        NullableBigIntVector bigIntVector = (NullableBigIntVector) v;
        Long value = groupScan.getPartitionValue(path, column, Long.class);
        if (value == null) {
            bigIntVector.getMutator().setNull(index);
        } else {
            bigIntVector.getMutator().setSafe(index, value);
        }
        return;
    }
    case FLOAT4: {
        NullableFloat4Vector float4Vector = (NullableFloat4Vector) v;
        Float value = groupScan.getPartitionValue(path, column, Float.class);
        if (value == null) {
            float4Vector.getMutator().setNull(index);
        } else {
            float4Vector.getMutator().setSafe(index, value);
        }
        return;
    }
    case FLOAT8: {
        NullableFloat8Vector float8Vector = (NullableFloat8Vector) v;
        Double value = groupScan.getPartitionValue(path, column, Double.class);
        if (value == null) {
            float8Vector.getMutator().setNull(index);
        } else {
            float8Vector.getMutator().setSafe(index, value);
        }
        return;
    }
    case VARBINARY: {
        NullableVarBinaryVector varBinaryVector = (NullableVarBinaryVector) v;
        Object s = groupScan.getPartitionValue(path, column, Object.class);
        byte[] bytes;
        if (s == null) {
            varBinaryVector.getMutator().setNull(index);
            return;
        } else {
            bytes = getBytes(type, s);
        }
        varBinaryVector.getMutator().setSafe(index, bytes, 0, bytes.length);
        return;
    }
    case VARDECIMAL: {
        NullableVarDecimalVector decimalVector = (NullableVarDecimalVector) v;
        Object s = groupScan.getPartitionValue(path, column, Object.class);
        byte[] bytes;
        if (s == null) {
            decimalVector.getMutator().setNull(index);
            return;
        } else if (s instanceof Integer) {
            bytes = Ints.toByteArray((int) s);
        } else if (s instanceof Long) {
            bytes = Longs.toByteArray((long) s);
        } else {
            bytes = getBytes(type, s);
        }
        decimalVector.getMutator().setSafe(index, bytes, 0, bytes.length);
        return;
    }
    case DATE: {
        NullableDateVector dateVector = (NullableDateVector) v;
        Integer value = groupScan.getPartitionValue(path, column, Integer.class);
        if (value == null) {
            dateVector.getMutator().setNull(index);
        } else {
            dateVector.getMutator().setSafe(index, value * (long) DateTimeConstants.MILLIS_PER_DAY);
        }
        return;
    }
    case TIME: {
        NullableTimeVector timeVector = (NullableTimeVector) v;
        Integer value = groupScan.getPartitionValue(path, column, Integer.class);
        if (value == null) {
            timeVector.getMutator().setNull(index);
        } else {
            timeVector.getMutator().setSafe(index, value);
        }
        return;
    }
    case TIMESTAMP: {
        NullableTimeStampVector timeStampVector = (NullableTimeStampVector) v;
        Long value = groupScan.getPartitionValue(path, column, Long.class);
        if (value == null) {
            timeStampVector.getMutator().setNull(index);
        } else {
            timeStampVector.getMutator().setSafe(index, value);
        }
        return;
    }
    case VARCHAR: {
        NullableVarCharVector varCharVector = (NullableVarCharVector) v;
        Object s = groupScan.getPartitionValue(path, column, Object.class);
        byte[] bytes;
        if (s == null) {
            varCharVector.getMutator().setNull(index);
            return;
        } else {
            bytes = getBytes(type, s);
        }
        varCharVector.getMutator().setSafe(index, bytes, 0, bytes.length);
        return;
    }
    case INTERVAL: {
        NullableIntervalVector intervalVector = (NullableIntervalVector) v;
        Object s = groupScan.getPartitionValue(path, column, Object.class);
        byte[] bytes;
        if (s == null) {
            intervalVector.getMutator().setNull(index);
            return;
        } else {
            bytes = getBytes(type, s);
        }
        intervalVector.getMutator().setSafe(index, 1, ParquetReaderUtility.getIntFromLEBytes(bytes, 0),
                ParquetReaderUtility.getIntFromLEBytes(bytes, 4),
                ParquetReaderUtility.getIntFromLEBytes(bytes, 8));
        return;
    }
    default:
        throw new UnsupportedOperationException("Unsupported type: " + type);
    }
}

From source file:org.apache.drill.exec.store.avro.AvroRecordReader.java

License:Apache License

private void processPrimitive(final Object value, final Schema schema, final String fieldName,
        final MapOrListWriterImpl writer) {
    LogicalType logicalType = schema.getLogicalType();
    String logicalTypeName = logicalType != null ? logicalType.getName() : "";

    if (value == null) {
        return;/*from   w  w  w .ja  v  a  2  s.com*/
    }

    switch (schema.getType()) {
    case STRING:
        byte[] binary;
        final int length;
        if (value instanceof Utf8) {
            binary = ((Utf8) value).getBytes();
            length = ((Utf8) value).getByteLength();
        } else {
            binary = value.toString().getBytes(Charsets.UTF_8);
            length = binary.length;
        }
        ensure(length);
        buffer.setBytes(0, binary);
        writer.varChar(fieldName).writeVarChar(0, length, buffer);
        break;
    case INT:
        switch (logicalTypeName) {
        case "date":
            writer.date(fieldName).writeDate((int) value * (long) DateTimeConstants.MILLIS_PER_DAY);
            break;
        case "time-millis":
            writer.time(fieldName).writeTime((Integer) value);
            break;
        default:
            writer.integer(fieldName).writeInt((Integer) value);
        }
        break;
    case LONG:
        switch (logicalTypeName) {
        case "date":
            writer.date(fieldName).writeDate((Long) value);
            break;
        case "time-micros":
            writer.time(fieldName).writeTime((int) ((long) value / 1000));
            break;
        case "timestamp-millis":
            writer.timeStamp(fieldName).writeTimeStamp((Long) value);
            break;
        case "timestamp-micros":
            writer.timeStamp(fieldName).writeTimeStamp((long) value / 1000);
            break;
        default:
            writer.bigInt(fieldName).writeBigInt((Long) value);
        }
        break;
    case FLOAT:
        writer.float4(fieldName).writeFloat4((Float) value);
        break;
    case DOUBLE:
        writer.float8(fieldName).writeFloat8((Double) value);
        break;
    case BOOLEAN:
        writer.bit(fieldName).writeBit((Boolean) value ? 1 : 0);
        break;
    case BYTES:
        final ByteBuffer buf = (ByteBuffer) value;
        length = buf.remaining();
        ensure(length);
        buffer.setBytes(0, buf);
        switch (logicalTypeName) {
        case "decimal":
            ParquetReaderUtility.checkDecimalTypeEnabled(optionManager);
            LogicalTypes.Decimal decimalType = (LogicalTypes.Decimal) logicalType;
            writer.varDecimal(fieldName, decimalType.getScale(), decimalType.getPrecision()).writeVarDecimal(0,
                    length, buffer, decimalType.getScale(), decimalType.getPrecision());
            break;
        default:
            writer.binary(fieldName).writeVarBinary(0, length, buffer);
        }
        break;
    case NULL:
        // Nothing to do for null type
        break;
    case ENUM:
        final String symbol = value.toString();
        final byte[] b;
        try {
            b = symbol.getBytes(Charsets.UTF_8.name());
        } catch (UnsupportedEncodingException e) {
            throw new DrillRuntimeException("Unable to read enum value for field: " + fieldName, e);
        }
        ensure(b.length);
        buffer.setBytes(0, b);
        writer.varChar(fieldName).writeVarChar(0, b.length, buffer);
        break;
    case FIXED:
        GenericFixed genericFixed = (GenericFixed) value;
        switch (logicalTypeName) {
        case "decimal":
            ParquetReaderUtility.checkDecimalTypeEnabled(optionManager);
            LogicalTypes.Decimal decimalType = (LogicalTypes.Decimal) logicalType;
            writer.varDecimal(fieldName, decimalType.getScale(), decimalType.getPrecision()).writeVarDecimal(
                    new BigDecimal(new BigInteger(genericFixed.bytes()), decimalType.getScale()));
            break;
        default:
            throw new UnsupportedOperationException("Unimplemented type: " + schema.getType().toString());
        }
        break;
    default:
        throw new DrillRuntimeException("Unhandled Avro type: " + schema.getType().toString());
    }
}

From source file:org.apache.drill.exec.store.parquet.stat.ParquetFooterStatCollector.java

License:Apache License

private static long convertToDrillDateValue(int dateValue, boolean isDateCorrect) {
    // See DRILL-4203 for the background regarding date type corruption issue in Drill CTAS prior to 1.9.0 release.
    if (isDateCorrect) {
        return dateValue * (long) DateTimeConstants.MILLIS_PER_DAY;
    } else {/*  www  .jav a2  s. co m*/
        return (dateValue - ParquetReaderUtility.CORRECT_CORRUPT_DATE_SHIFT) * DateTimeConstants.MILLIS_PER_DAY;
    }
}

From source file:org.apache.drill.exec.store.parquet.stat.ParquetMetaStatCollector.java

License:Apache License

private static long convertToDrillDateValue(int dateValue) {
    return dateValue * (long) DateTimeConstants.MILLIS_PER_DAY;
}

From source file:org.integratedmodelling.time.literals.DurationValue.java

License:Open Source License

/**
 * Localize a duration to an extent starting at the current moment
 * using the same resolution that was implied in the generating 
 * text. For example, if the duration was one year, localize to the 
 * current year (jan 1st to dec 31st). Return the start and end points
 * of the extent.//from   w ww.j  ava2  s . c  om
 * 
 * @return
 */
public Pair<TimeValue, TimeValue> localize() {

    DateTime date = new DateTime();
    TimeValue start = null, end = null;
    long val = value;

    switch (precision) {

    case TemporalPrecision.MILLISECOND:
        start = new TimeValue(date);
        end = new TimeValue(date.plus(val));
        break;
    case TemporalPrecision.SECOND:
        val = value / DateTimeConstants.MILLIS_PER_SECOND;
        start = new TimeValue(new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(),
                date.getHourOfDay(), date.getMinuteOfHour(), date.getSecondOfMinute(), 0));
        end = new TimeValue(start.getTimeData().plusSeconds((int) val));
        break;
    case TemporalPrecision.MINUTE:
        val = value / DateTimeConstants.MILLIS_PER_MINUTE;
        start = new TimeValue(new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(),
                date.getHourOfDay(), date.getMinuteOfHour(), 0, 0));
        end = new TimeValue(start.getTimeData().plusMinutes((int) val));
        break;
    case TemporalPrecision.HOUR:
        val = value / DateTimeConstants.MILLIS_PER_HOUR;
        start = new TimeValue(new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(),
                date.getHourOfDay(), 0, 0, 0));
        end = new TimeValue(start.getTimeData().plusHours((int) val));
        break;
    case TemporalPrecision.DAY:
        val = value / DateTimeConstants.MILLIS_PER_DAY;
        start = new TimeValue(
                new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), 0, 0, 0, 0));
        end = new TimeValue(start.getTimeData().plusDays((int) val));
        break;
    case TemporalPrecision.MONTH:
        start = new TimeValue(new DateTime(date.getYear(), date.getMonthOfYear(), 1, 0, 0, 0, 0));
        end = new TimeValue(start.getTimeData().plusMonths(origQuantity));
        break;
    case TemporalPrecision.YEAR:
        start = new TimeValue(new DateTime(date.getYear(), 1, 1, 0, 0, 0, 0));
        end = new TimeValue(start.getTimeData().plusYears(origQuantity));
        break;
    }

    return new Pair<TimeValue, TimeValue>(start, end);
}

From source file:org.netxilia.api.value.DateValue.java

License:Open Source License

@Override
public Double getNumberValue() {
    return value != null
            ? (double) new Duration(ORIGIN, value.toDateTime(ORIGIN)).getMillis()
                    / DateTimeConstants.MILLIS_PER_DAY
            : Double.valueOf(0);// w w  w  . ja v  a2 s .  co m
}