Example usage for org.joda.time MutableDateTime setMillis

List of usage examples for org.joda.time MutableDateTime setMillis

Introduction

In this page you can find the example usage for org.joda.time MutableDateTime setMillis.

Prototype

public void setMillis(ReadableInstant instant) 

Source Link

Document

Sets the millisecond instant of this instant from another.

Usage

From source file:org.elasticsearch.index.field.data.longs.SingleValueLongFieldData.java

License:Apache License

@Override
public void forEachValueInDoc(int docId, DateValueInDocProc proc) {
    int loc = ordinals[docId];
    if (loc == 0) {
        return;//w w w .j a v a2s . c  o  m
    }
    MutableDateTime dateTime = dateTimeCache.get().get();
    dateTime.setMillis(values[loc]);
    proc.onValue(docId, dateTime);
}

From source file:org.elasticsearch.index.field.data.longs.SingleValueLongFieldData.java

License:Apache License

@Override
public void forEachValueInDoc(int docId, MutableDateTime dateTime, DateValueInDocProc proc) {
    int loc = ordinals[docId];
    if (loc == 0) {
        return;/*from w w w  .ja v  a 2  s  .c  om*/
    }
    dateTime.setMillis(values[loc]);
    proc.onValue(docId, dateTime);
}

From source file:org.elasticsearch.script.expression.DateObjectValueSource.java

License:Apache License

@Override
@SuppressWarnings("rawtypes") // ValueSource uses a rawtype
public FunctionValues getValues(Map context, LeafReaderContext leaf) throws IOException {
    AtomicNumericFieldData leafData = (AtomicNumericFieldData) fieldData.load(leaf);
    MutableDateTime joda = new MutableDateTime(0, DateTimeZone.UTC);
    NumericDoubleValues docValues = multiValueMode.select(leafData.getDoubleValues(), 0d);
    return new DoubleDocValues(this) {
        @Override/*w w w .ja  v  a2  s  .  c om*/
        public double doubleVal(int docId) {
            long millis = (long) docValues.get(docId);
            joda.setMillis(millis);
            return function.applyAsInt(joda);
        }
    };
}

From source file:org.talend.components.netsuite.avro.converter.XMLGregorianCalendarToDateTimeConverter.java

License:Open Source License

@Override
public XMLGregorianCalendar convertToDatum(Object timestamp) {
    if (timestamp == null) {
        return null;
    }/*  w  ww.  j  a v  a 2  s.com*/

    long timestampMillis;
    if (timestamp instanceof Long) {
        timestampMillis = ((Long) timestamp).longValue();
    } else if (timestamp instanceof Date) {
        timestampMillis = ((Date) timestamp).getTime();
    } else {
        throw new IllegalArgumentException("Unsupported Avro timestamp value: " + timestamp);
    }

    MutableDateTime dateTime = new MutableDateTime();
    dateTime.setMillis(timestampMillis);

    XMLGregorianCalendar xts = datatypeFactory.newXMLGregorianCalendar();
    xts.setYear(dateTime.getYear());
    xts.setMonth(dateTime.getMonthOfYear());
    xts.setDay(dateTime.getDayOfMonth());
    xts.setHour(dateTime.getHourOfDay());
    xts.setMinute(dateTime.getMinuteOfHour());
    xts.setSecond(dateTime.getSecondOfMinute());
    xts.setMillisecond(dateTime.getMillisOfSecond());
    xts.setTimezone(dateTime.getZone().toTimeZone().getOffset(dateTime.getMillis()) / 60000);

    return xts;
}