Example usage for org.joda.time DateTimeZone UTC

List of usage examples for org.joda.time DateTimeZone UTC

Introduction

In this page you can find the example usage for org.joda.time DateTimeZone UTC.

Prototype

DateTimeZone UTC

To view the source code for org.joda.time DateTimeZone UTC.

Click Source Link

Document

The time zone for Universal Coordinated Time

Usage

From source file:com.mfizz.binlog.impl.BinlogFileWriterImpl.java

License:Apache License

@Override
public BinlogRecordFileInfo writeEvent(EventType type, DateTime timestamp, String info,
        Map<String, String> optionalParameters) throws IOException, BinlogException {
    if (timestamp == null) {
        timestamp = new DateTime(DateTimeZone.UTC);
    }/*  www .j a v a  2 s . co m*/
    return write(createRecordHeaderForEvent(timestamp, type, info, optionalParameters), null);
}

From source file:com.mfizz.binlog.impl.BinloggerImpl.java

License:Apache License

public BinlogRecordFileInfo writeEvent(DateTime timestamp, EventType type, String info,
        Map<String, String> optionalParameters) throws IOException, BinlogException, InterruptedException {
    // we always want a timestamp
    if (timestamp == null) {
        timestamp = new DateTime(DateTimeZone.UTC);
    }//from  w ww .  j  av  a 2s.  co  m
    BinlogRecordHeader recordHeader = BinlogFileWriterImpl.createRecordHeaderForEvent(timestamp, type, info,
            optionalParameters);
    return write(recordHeader, null);
}

From source file:com.mfizz.binlog.protobuf.ProtobufBinlogFileTranscoder.java

License:Apache License

@Override
protected BinlogFileHeader doCreateBinlogFileHeader(byte[] data) throws BinlogException {
    try {//from   ww w . ja  va 2  s  .  c  o m
        BinlogProtos.BinlogFileHeader protobufHeader = BinlogProtos.BinlogFileHeader.parseFrom(data);

        WritableBinlogFileHeader header = new BinlogFileHeaderImpl();
        if (protobufHeader.hasRecordLengthByteLength()) {
            header.setRecordLengthByteLength(protobufHeader.getRecordLengthByteLength());
        }
        if (protobufHeader.hasCreateDateTime()) {
            // always create a DateTime in UTC
            header.setCreateDateTime(new DateTime(protobufHeader.getCreateDateTime(), DateTimeZone.UTC));
        }
        if (protobufHeader.hasName()) {
            header.setName(protobufHeader.getName());
        }
        if (protobufHeader.hasContentType()) {
            header.setContentType(protobufHeader.getContentType());
        }
        for (BinlogProtos.KeyValue protobufKeyValue : protobufHeader.getOptionalParameterList()) {
            // check for duplicates (maybe warn here?)
            if (header.hasOptionalParameter(protobufKeyValue.getKey())) {
                logger.warn("Duplicate key [" + protobufKeyValue.getKey()
                        + "] found in binlog file header; the value will be overwritten with the new one");
            }
            header.setOptionalParameter(protobufKeyValue.getKey(), protobufKeyValue.getValue());
        }
        return header;
    } catch (Exception e) {
        throw new BinlogException("Unable to convert bytes into BinlogFileHeader: " + e.getMessage(), e);
    }
}

From source file:com.mfizz.binlog.protobuf.ProtobufBinlogFileTranscoder.java

License:Apache License

@Override
protected BinlogRecordHeader doCreateBinlogRecordHeader(byte[] data) throws BinlogException {
    try {/*www . j ava 2  s. c  om*/
        BinlogProtos.BinlogRecordHeader protobufHeader = BinlogProtos.BinlogRecordHeader.parseFrom(data);

        WritableBinlogRecordHeader header = new BinlogRecordHeaderImpl();
        if (protobufHeader.hasCreateDateTime()) {
            // always create a DateTime in UTC
            header.setCreateDateTime(new DateTime(protobufHeader.getCreateDateTime(), DateTimeZone.UTC));
        }
        if (protobufHeader.hasId()) {
            header.setId(protobufHeader.getId());
        }
        if (protobufHeader.hasUserDefinedType()) {
            header.setUserDefinedType(protobufHeader.getUserDefinedType());
        }
        for (BinlogProtos.KeyValue protobufKeyValue : protobufHeader.getOptionalParameterList()) {
            // check for duplicates (maybe warn here?)
            if (header.hasOptionalParameter(protobufKeyValue.getKey())) {
                logger.warn("Duplicate key [" + protobufKeyValue.getKey()
                        + "] found in binlog record header; the value will be overwritten with the new one");
            }
            header.setOptionalParameter(protobufKeyValue.getKey(), protobufKeyValue.getValue());
        }

        // does this have an event?
        if (protobufHeader.hasEventId()) {
            // create an event
            WritableBinlogRecordHeaderEvent event = new BinlogRecordHeaderEventImpl();
            event.setId(protobufHeader.getEventId());

            // try to map types
            event.setType(EventType.get(event.getId()));

            if (protobufHeader.hasEventName()) {
                event.setName(protobufHeader.getEventName());
            }
            if (protobufHeader.hasEventInfo()) {
                event.setInfo(protobufHeader.getEventInfo());
            }

            header.setEvent(event);
        }

        return header;
    } catch (Exception e) {
        throw new BinlogException("Unable to convert bytes into BinlogRecordHeader: " + e.getMessage(), e);
    }
}

From source file:com.mfizz.binlog.type.DateTimePeriod.java

License:Apache License

private DateTimePeriod(String pattern, long millis) {
    this.pattern = pattern;
    if (pattern != null) {
        this.formatter = DateTimeFormat.forPattern(pattern).withZone(DateTimeZone.UTC);
    }//from  w w  w.  j  av  a2 s  .c o  m
    this.millis = millis;
}

From source file:com.mfizz.binlog.type.DateTimePeriod.java

License:Apache License

/**
 * Calculates the first timestamp in the period representing the given
 * currentTimeMillis.//from   w w w .  j  a v  a2s .c  o m
 */
public long floorMillis(long currentTimeMillis) {
    DateTime dt = new DateTime(currentTimeMillis, DateTimeZone.UTC);
    if (this == MINUTE) {
        return DateTimeUtil.floorToMinute(dt).getMillis();
    } else if (this == FIVE_MINUTES) {
        return DateTimeUtil.floorToFiveMinutes(dt).getMillis();
    } else if (this == TEN_MINUTES) {
        return DateTimeUtil.floorToTenMinutes(dt).getMillis();
    } else if (this == QUARTER_HOUR) {
        return DateTimeUtil.floorToQuarterHour(dt).getMillis();
    } else if (this == HALF_HOUR) {
        return DateTimeUtil.floorToHalfHour(dt).getMillis();
    } else if (this == HOUR) {
        return DateTimeUtil.floorToHour(dt).getMillis();
    } else if (this == DAY) {
        return DateTimeUtil.floorToDay(dt).getMillis();
    } else {
        return currentTimeMillis;
    }
}

From source file:com.mfizz.observer.core.ServiceObserver.java

License:Apache License

public DateTime getLastSnapshotAllDateTime() {
    SnapshotAllResult result = this.lastSnapshotAllResult.get();
    if (result == null) {
        return null;
    }//w  ww  .j a  v  a2  s  .co m
    return new DateTime(result.getBeginTimestamp(), DateTimeZone.UTC);
}

From source file:com.mfizz.observer.server.IndexResource.java

License:Apache License

@GET
public IndexView get() {
    return new IndexView(new DateTime(DateTimeZone.UTC), configuration, Version.getLongVersion(), sos);
}

From source file:com.mfizz.util.DateTimeUtil.java

License:Apache License

/**
 * Get the current time as a UTC-based DateTime
 * @return A UTC DateTime/*www . j  a  va  2 s  . c o  m*/
 */
public static DateTime nowUTC() {
    return new DateTime(DateTimeZone.UTC);
}

From source file:com.microsoft.azure.keyvault.models.Attributes.java

License:Open Source License

/**
 * Get the notBefore value./*from  ww w .  j  av  a  2s . co m*/
 *
 * @return the notBefore value
 */
public DateTime notBefore() {
    if (this.notBefore == null) {
        return null;
    }
    return new DateTime(this.notBefore * 1000L, DateTimeZone.UTC);
}