Example usage for org.joda.time.chrono ISOChronology dayOfYear

List of usage examples for org.joda.time.chrono ISOChronology dayOfYear

Introduction

In this page you can find the example usage for org.joda.time.chrono ISOChronology dayOfYear.

Prototype

public final DateTimeField dayOfYear() 

Source Link

Usage

From source file:com.facebook.presto.type.TimestampOperators.java

License:Apache License

@ScalarOperator(CAST)
@SqlType(DateType.class)
public static long castToDate(ConnectorSession session, @SqlType(TimestampType.class) long value) {
    // round down the current timestamp to days
    ISOChronology chronology = getChronology(session.getTimeZoneKey());
    long date = chronology.dayOfYear().roundFloor(value);
    // date is currently midnight in timezone of the session
    // convert to UTC
    return date + chronology.getZone().getOffset(date);
}

From source file:com.facebook.presto.type.TimestampWithTimeZoneOperators.java

License:Apache License

@ScalarOperator(CAST)
@SqlType(DateType.class)
public static long castToDate(@SqlType(TimestampWithTimeZoneType.class) long value) {
    // round down the current timestamp to days
    ISOChronology chronology = unpackChronology(value);
    long date = chronology.dayOfYear().roundFloor(unpackMillisUtc(value));
    // date is currently midnight in timezone of the original value
    // convert to UTC
    return date + chronology.getZone().getOffset(date);
}

From source file:io.prestosql.type.TimestampOperators.java

License:Apache License

@ScalarFunction("date")
@ScalarOperator(CAST)//from w  ww  .  j  av  a 2 s  .  co m
@SqlType(StandardTypes.DATE)
public static long castToDate(ConnectorSession session, @SqlType(StandardTypes.TIMESTAMP) long value) {
    ISOChronology chronology;
    if (session.isLegacyTimestamp()) {
        // round down the current timestamp to days
        chronology = getChronology(session.getTimeZoneKey());
        long date = chronology.dayOfYear().roundFloor(value);
        // date is currently midnight in timezone of the session
        // convert to UTC
        long millis = date + chronology.getZone().getOffset(date);
        return TimeUnit.MILLISECONDS.toDays(millis);
    } else {
        return TimeUnit.MILLISECONDS.toDays(value);
    }
}

From source file:io.prestosql.type.TimestampWithTimeZoneOperators.java

License:Apache License

@ScalarFunction("date")
@ScalarOperator(CAST)/*w  w w  .ja v  a2 s.c o m*/
@SqlType(StandardTypes.DATE)
public static long castToDate(@SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long value) {
    // round down the current timestamp to days
    ISOChronology chronology = unpackChronology(value);
    long date = chronology.dayOfYear().roundFloor(unpackMillisUtc(value));
    // date is currently midnight in timezone of the original value
    // convert to UTC
    long millis = date + chronology.getZone().getOffset(date);
    return TimeUnit.MILLISECONDS.toDays(millis);
}