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.microsoft.azure.keyvault.models.Attributes.java

License:Open Source License

/**
 * Set the notBefore value./*  w ww.  j a va  2s . co  m*/
 *
 * @param notBefore the notBefore value to set
 * @return the Attributes object itself.
 */
public Attributes withNotBefore(DateTime notBefore) {
    if (notBefore == null) {
        this.notBefore = null;
    } else {
        this.notBefore = notBefore.toDateTime(DateTimeZone.UTC).getMillis() / 1000;
    }
    return this;
}

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

License:Open Source License

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

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

License:Open Source License

/**
 * Set the expires value./*  w w w. j  a v  a  2s  . c om*/
 *
 * @param expires the expires value to set
 * @return the Attributes object itself.
 */
public Attributes withExpires(DateTime expires) {
    if (expires == null) {
        this.expires = null;
    } else {
        this.expires = expires.toDateTime(DateTimeZone.UTC).getMillis() / 1000;
    }
    return this;
}

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

License:Open Source License

/**
 * Get the created value.// w  w  w .  j  av a2  s.  c  o  m
 *
 * @return the created value
 */
public DateTime created() {
    if (this.created == null) {
        return null;
    }
    return new DateTime(this.created * 1000L, DateTimeZone.UTC);
}

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

License:Open Source License

/**
 * Get the updated value./*w w w  .  ja  v a  2  s .  c o  m*/
 *
 * @return the updated value
 */
public DateTime updated() {
    if (this.updated == null) {
        return null;
    }
    return new DateTime(this.updated * 1000L, DateTimeZone.UTC);
}

From source file:com.microsoft.azurebatch.jenkins.azurebatch.AzureBatchHelper.java

License:Open Source License

/**
 * Extend pool job's timeout// w ww.j a  v  a 2 s .c  o  m
 * @param extraTimeoutInMin Extra timeout in minutes
 * @throws BatchErrorException
 * @throws IOException 
 */
private void extendPoolJobTimeout(int extraTimeoutInMin) throws BatchErrorException, IOException {
    CloudJob job = client.jobOperations().getJob(poolJobId);

    DateTime jobCreatedTime = job.creationTime();
    DateTime now = new DateTime(DateTimeZone.UTC);

    // Add some safe buffer timeout to the new job timeout
    final int safeMoreTimeoutInMin = 15;
    int newJobTimeoutInMin = (int) ((now.getMillis() - jobCreatedTime.getMillis()) / 1000 / 60)
            + extraTimeoutInMin + safeMoreTimeoutInMin;

    JobConstraints jobConstraints = new JobConstraints();
    jobConstraints.withMaxWallClockTime(Period.minutes(newJobTimeoutInMin));

    JobPatchParameter jpp = new JobPatchParameter();
    jpp.withConstraints(jobConstraints);

    client.jobOperations().patchJob(poolJobId, jpp);
    Logger.log(listener, "Set poolJob %s new timeout to %d minutes.", poolJobId, newJobTimeoutInMin);
}

From source file:com.microsoft.rest.serializer.DateTimeSerializer.java

License:Open Source License

@Override
public void serialize(DateTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
    if (provider.isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)) {
        jgen.writeNumber(value.getMillis());
    } else {//from   w w w  .j  a  va  2  s  .c om
        value = value.withZone(DateTimeZone.UTC);
        jgen.writeString(value.toString(ISODateTimeFormat.dateTime()));
    }
}

From source file:com.mogwee.push.FeedbackService.java

License:Apache License

public void processFailedTokens(FailedTokenProcessor processor) throws Exception {
    Socket socket = null;//from  ww  w  . j a  v  a 2  s  . c o  m

    try {
        socket = socketFactory.createSocket();

        DataInputStream stream = new DataInputStream(new BufferedInputStream(socket.getInputStream(), 8096));
        byte[] tokenBuffer = new byte[28];

        while (true) {
            ReadableDateTime timestamp;

            try {
                timestamp = new DateTime(stream.readInt() * 1000L, DateTimeZone.UTC);
            } catch (EOFException e) {
                LOG.debug(e, "Encountered EOF signalling end of token stream");

                return;
            }

            int tokenLength = stream.readUnsignedShort();

            if (tokenBuffer.length < tokenLength) {
                LOG.infof("Increasing token buffer size to %s (this is unexpected)", tokenLength);
                tokenBuffer = new byte[tokenLength];
            }

            int bytesRead = stream.read(tokenBuffer, 0, tokenLength);
            StringBuilder tokenBuilder = new StringBuilder(2 * tokenLength);

            if (bytesRead != tokenLength) {
                LOG.warnf("Expected to read %s bytes, but only got %s", tokenLength, bytesRead);
                tokenLength = bytesRead;
            }

            for (int i = 0; i < tokenLength; ++i) {
                int b = tokenBuffer[i];

                tokenBuilder.append(HEX_CHARS[(b >>> 4) & 0xf]);
                tokenBuilder.append(HEX_CHARS[b & 0xf]);
            }

            String token = tokenBuilder.toString();

            LOG.debugf("Processing failure of %s that occurred %s", token, timestamp);
            processor.tokenWithFailure(token, timestamp);
        }
    } finally {
        CloseableUtil.closeQuietly(socket);
    }
}

From source file:com.moss.joda.time.xml.InstantAdapter.java

License:Open Source License

@Override
public String marshal(Instant arg0) throws Exception {
    if (arg0 == null)
        return null;
    return format.print(arg0.toDateTime(DateTimeZone.UTC));
}

From source file:com.moss.joda.time.xml.InstantAdapter.java

License:Open Source License

@Override
public Instant unmarshal(String arg0) throws Exception {
    if (arg0 == null)
        return null;
    return format.parseDateTime(arg0).withZoneRetainFields(DateTimeZone.UTC).toInstant();
}