Example usage for org.joda.time LocalTime fromMillisOfDay

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

Introduction

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

Prototype

public static LocalTime fromMillisOfDay(long millisOfDay) 

Source Link

Document

Constructs a LocalTime from the specified millis of day using the ISO chronology.

Usage

From source file:aiai.ai.yaml.env.TimePeriods.java

License:Open Source License

public boolean isCurrentTimeActive() {
    return isActive(LocalTime.fromMillisOfDay(System.currentTimeMillis()));
}

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

License:Apache License

@Override
public LocalTime getNullableResult(ResultSet rs, String columnName) throws SQLException {
    Time time = rs.getTime(columnName);
    if (time == null) {
        return null;
    }// ww w .j a v  a2  s .c  o m
    return LocalTime.fromMillisOfDay(time.getTime());
}

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

License:Apache License

@Override
public LocalTime getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
    Time time = rs.getTime(columnIndex);
    if (time == null) {
        return null;
    }/*from   ww w.j  a va2s .  c  o  m*/
    return LocalTime.fromMillisOfDay(time.getTime());
}

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

License:Apache License

@Override
public LocalTime getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
    Time time = cs.getTime(columnIndex);
    if (time == null) {
        return null;
    }// w w  w  .  j  a v  a2s.  c  om
    return LocalTime.fromMillisOfDay(time.getTime());
}

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

License:Apache License

@Override
public LocalTime getValue(ResultSet rs, int startIndex) throws SQLException {
    Time time = rs.getTime(startIndex);
    if (time == null) {
        return null;
    }//from  w w  w . ja v  a 2  s  . c o  m
    return LocalTime.fromMillisOfDay(time.getTime());
}

From source file:com.codeabovelab.dm.cluman.ui.UiUtils.java

License:Apache License

public static String convertToStringFromJiffies(Long jiffies) {
    LocalTime timeOfDay = LocalTime.fromMillisOfDay(jiffies / 1000_000L);
    String time = timeOfDay.toString("HH:mm:ss");
    return time;//from   w ww .j  a v  a 2 s . c  o m
}

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

License:Apache License

@Override
public LocalTime deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion) throws InvalidTypeException {
    if (bytes == null || bytes.remaining() == 0)
        return null;
    long nanosOfDay = bigint().deserializeNoBoxing(bytes, protocolVersion);
    return LocalTime.fromMillisOfDay(NANOSECONDS.toMillis(nanosOfDay));
}

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

License:Apache License

@Override
public LocalTime parse(String value) {
    if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL"))
        return null;

    // enclosing single quotes required, even for long literals
    if (!ParseUtils.isQuoted(value))
        throw new InvalidTypeException("time values must be enclosed by single quotes");
    value = value.substring(1, value.length() - 1);

    if (ParseUtils.isLongLiteral(value)) {
        long nanosOfDay;
        try {/*w ww.java2 s .c  o m*/
            nanosOfDay = Long.parseLong(value);
        } catch (NumberFormatException e) {
            throw new InvalidTypeException(String.format("Cannot parse time value from \"%s\"", value), e);
        }
        return LocalTime.fromMillisOfDay(NANOSECONDS.toMillis(nanosOfDay));
    }

    try {
        return LocalTime.parse(value);
    } catch (RuntimeException e) {
        throw new InvalidTypeException(String.format("Cannot parse time value from \"%s\"", value), e);
    }
}

From source file:com.github.cassandra.jdbc.provider.datastax.codecs.JavaSqlTimeCodec.java

License:Apache License

@Override
public Time deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion) throws InvalidTypeException {
    if (bytes == null || bytes.remaining() == 0)
        return null;
    long nanosOfDay = bigint().deserializeNoBoxing(bytes, protocolVersion);
    return new Time(LocalTime.fromMillisOfDay(nanosOfDay / 1000000L).toDateTimeToday().getMillis());
}

From source file:com.github.cassandra.jdbc.provider.datastax.codecs.JavaSqlTimeCodec.java

License:Apache License

@Override
public Time parse(String value) {
    if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL"))
        return null;

    // enclosing single quotes required, even for long literals
    if (!ParseUtils.isQuoted(value))
        throw new InvalidTypeException("time values must be enclosed by single quotes");
    value = value.substring(1, value.length() - 1);

    if (ParseUtils.isLongLiteral(value)) {
        long nanosOfDay;
        try {/*from w w w. j av a2 s.  c  om*/
            nanosOfDay = Long.parseLong(value);
        } catch (NumberFormatException e) {
            throw new InvalidTypeException(String.format("Cannot parse time value from \"%s\"", value), e);
        }
        return new Time(LocalTime.fromMillisOfDay(nanosOfDay / 1000000L).getMillisOfSecond());
    }

    try {
        return new Time(LocalTime.parse(value).toDateTimeToday().getMillis());
    } catch (RuntimeException e) {
        throw new InvalidTypeException(String.format("Cannot parse time value from \"%s\"", value), e);
    }
}