Example usage for org.joda.time LocalTime getMillisOfDay

List of usage examples for org.joda.time LocalTime getMillisOfDay

Introduction

In this page you can find the example usage for org.joda.time LocalTime getMillisOfDay.

Prototype

public int getMillisOfDay() 

Source Link

Document

Get the millis of day field value.

Usage

From source file:cherry.foundation.type.mybatis.JodaLocalTimeTypeHandler.java

License:Apache License

@Override
public void setNonNullParameter(PreparedStatement ps, int i, LocalTime parameter, JdbcType jdbcType)
        throws SQLException {
    ps.setTime(i, new Time(parameter.getMillisOfDay()));
}

From source file:cherry.foundation.type.querydsl.LocalTimeType.java

License:Apache License

@Override
public void setValue(PreparedStatement st, int startIndex, LocalTime value) throws SQLException {
    st.setTime(startIndex, new Time(value.getMillisOfDay()));
}

From source file:com.datastax.driver.extras.codecs.joda.LocalTimeCodec.java

License:Apache License

@Override
public ByteBuffer serialize(LocalTime value, ProtocolVersion protocolVersion) throws InvalidTypeException {
    if (value == null)
        return null;
    return bigint().serializeNoBoxing(MILLISECONDS.toNanos(value.getMillisOfDay()), protocolVersion);
}

From source file:com.querydsl.sql.types.LocalTimeType.java

License:Apache License

@Override
public void setValue(PreparedStatement st, int startIndex, LocalTime value) throws SQLException {
    st.setTime(startIndex, new Time(value.getMillisOfDay()), utc());
}

From source file:com.sam.moca.server.expression.operators.arith.MinusExpression.java

License:Open Source License

protected MocaValue doOper(MocaValue left, MocaValue right) {
    if (left.getType() == MocaType.DATETIME) {
        if (right.getType() == MocaType.DOUBLE || right.getType() == MocaType.INTEGER) {
            Date d = left.asDate();

            // If the left side is null, return a null result.
            if (d == null) {
                return new MocaValue(MocaType.DATETIME, null);
            }//w  ww.  j  a v a2s.  c  om

            LocalDateTime dt = new LocalDateTime(d);

            int wholeDays = right.asInt();
            double dayPart = right.asDouble() - wholeDays;
            int msDiff = (int) (dayPart * 1000.0 * 3600.0 * 24.0);

            dt = dt.minusDays(wholeDays).minusMillis(msDiff);

            return new MocaValue(MocaType.DATETIME, dt.toDateTime().toDate());
        } else if (right.getType() == MocaType.DATETIME) {
            Date leftDate = left.asDate();
            Date rightDate = right.asDate();

            // If either the left side or the right side is null, return null
            if (leftDate == null || rightDate == null) {
                return new MocaValue(MocaType.DOUBLE, null);
            }

            DateTime leftDt = new DateTime(leftDate);
            DateTime rightDt = new DateTime(rightDate);

            int fullDays = Days.daysBetween(rightDt, leftDt).getDays();

            LocalTime leftTime = new LocalTime(leftDt);
            LocalTime rightTime = new LocalTime(rightDt);

            int ms = leftTime.getMillisOfDay() - rightTime.getMillisOfDay();
            double partial = ((double) ms / (1000.0 * 3600.0 * 24.0));

            if (partial < 0.0 && leftDate.after(rightDate)) {
                partial += 1.0;
            } else if (partial > 0.0 && rightDate.after(leftDate)) {
                partial -= 1.0;
            }

            double daysDiff = (double) fullDays + partial;

            return new MocaValue(MocaType.DOUBLE, daysDiff);
        }
    } else {
        if (left.getType() == MocaType.DOUBLE || right.getType() == MocaType.DOUBLE) {
            return new MocaValue(MocaType.DOUBLE, Double.valueOf(left.asDouble() - right.asDouble()));
        } else {
            return new MocaValue(MocaType.INTEGER, Integer.valueOf(left.asInt() - right.asInt()));
        }
    }
    return null;
}

From source file:com.tkmtwo.sarapi.convert.LocalTimeToValueConverter.java

License:Apache License

@Override
public Value convert(LocalTime lt) {
    if (lt == null) {
        return new Value();
    }/*from  w w w  . ja  v  a2s.c om*/
    Time t = new Time(lt.getMillisOfDay() / 1000L);
    return new Value(t);
}

From source file:de.jpaw.bonaparte.core.AppendableComposer.java

License:Apache License

@Override
public void addField(TemporalElementaryDataItem di, LocalTime t) throws IOException {
    if (t != null) {
        int length = di.getFractionalSeconds();
        int millis = t.getMillisOfDay();
        if (di.getHhmmss()) {
            int tmpValue = millis / 60000; // minutes and hours
            tmpValue = (100 * (tmpValue / 60)) + (tmpValue % 60);
            work.append(Integer.toString((tmpValue * 100) + ((millis % 60000) / 1000)));
        } else {//from w  w w.j  a v  a2s . c o m
            work.append(Integer.toString(millis / 1000));
        }
        if (length > 0 && (millis % 1000) != 0) {
            // add milliseconds
            work.append('.');
            int milliSeconds = millis % 1000;
            lpad(Integer.toString(milliSeconds), 3, '0');
        }
        terminateField();
    } else {
        writeNull();
    }
}

From source file:de.jpaw.bonaparte.core.ByteArrayComposer.java

License:Apache License

@Override
public void addField(TemporalElementaryDataItem di, LocalTime t) {
    if (t != null) {
        int length = di.getFractionalSeconds();
        int millis = t.getMillisOfDay();
        if (di.getHhmmss()) {
            int tmpValue = millis / 60000; // minutes and hours
            tmpValue = (100 * (tmpValue / 60)) + (tmpValue % 60);
            work.appendAscii(Integer.toString((tmpValue * 100) + ((millis % 60000) / 1000)));
        } else {//  w  w  w. java 2s .  co m
            work.appendAscii(Integer.toString(millis / 1000));
        }
        if (length > 0 && (millis % 1000) != 0) {
            // add milliseconds
            work.append((byte) '.');
            int milliSeconds = millis % 1000;
            lpad(Integer.toString(milliSeconds), 3, (byte) '0');
        }
        terminateField();
    } else {
        writeNull();
    }
}

From source file:de.jpaw.bonaparte.core.ExternalizableComposer.java

License:Apache License

@Override
public void addField(TemporalElementaryDataItem di, LocalTime t) throws IOException {
    if (t == null) {
        out.writeByte(NULL_FIELD);//from   w w  w .  j av  a2s  . c  om
    } else {
        int millis = t.getMillisOfDay();
        out.writeByte(FRAC_SCALE_0 + 9);
        if (di.getHhmmss()) {
            // convert milliseconds to hhmmssfff format
            int tmp = millis / 60000; // number of minutes
            tmp = ((tmp / 60) * 100) + (tmp % 60);
            writeVarInt((tmp * 100000) + (millis % 60000));
        } else {
            writeVarInt(millis);
        }
    }
}

From source file:de.jpaw.bonaparte.util.DayTime.java

License:Apache License

/** Provides functionality to convert a Joda date to a GregorianCalendar. */
static public GregorianCalendar toCalendar(LocalTime when) {
    if (when == null) {
        return null;
    }//w ww. j  a  va 2s.  c  o m
    long millis = when.getMillisOfDay();
    GregorianCalendar then = new GregorianCalendar();
    then.setTimeInMillis(millis);
    return then;
}