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.arpnetworking.metrics.generator.client.GeneratorSink.java

License:Apache License

/**
 * {@inheritDoc}//from  www  . ja v a 2  s. c  o  m
 */
@Override
public void record(final Event event) {
    final HashMap<String, String> modified = Maps.newHashMap(event.getAnnotations());
    modified.put("_start", _time.withZone(DateTimeZone.UTC).toString());
    modified.put("_end", _time.withZone(DateTimeZone.UTC).toString());
    _wrapped.record(new TimeWarpEvent(modified, event));
}

From source file:com.arpnetworking.metrics.mad.PeriodWorker.java

License:Apache License

static DateTime getStartTime(final DateTime dateTime, final Period period) {
    // This effectively uses Jan 1, 1970 at 00:00:00 as the anchor point
    // for non-standard bucket sizes (e.g. 18 min) that do not divide
    // equally into an hour or day. Such use cases are rather uncommon.
    final long periodMillis = period.toStandardDuration().getMillis();
    final long dateTimeMillis = dateTime.getMillis();
    return new DateTime(dateTimeMillis - (dateTimeMillis % periodMillis), DateTimeZone.UTC);
}

From source file:com.auditbucket.engine.repo.neo4j.model.MetaHeaderNode.java

License:Open Source License

MetaHeaderNode() {

    DateTime now = new DateTime().toDateTime(DateTimeZone.UTC);
    this.dateCreated = now.toDate().getTime();
    this.lastUpdated = dateCreated;
}

From source file:com.auditbucket.engine.repo.neo4j.model.MetaHeaderNode.java

License:Open Source License

@Override
public void bumpUpdate() {
    lastUpdated = new DateTime().toDateTime(DateTimeZone.UTC).toDateTime().getMillis();
}

From source file:com.auditbucket.engine.repo.neo4j.model.TrackLogRelationship.java

License:Open Source License

protected TrackLogRelationship() {
    DateTime now = new DateTime().toDateTime(DateTimeZone.UTC);
    this.sysWhen = now.getMillis();
}

From source file:com.auditbucket.engine.repo.neo4j.model.TxRefNode.java

License:Open Source License

private TxStatus setStatus(TxStatus txStatus) {
    TxStatus previous = this.txStatus;
    this.txStatus = txStatus;
    this.txDate = DateTime.now(DateTimeZone.UTC).getMillis();
    return previous;
}

From source file:com.axelor.db.JpaFixture.java

License:Open Source License

@Transactional
public void load(String fixture) {

    final InputStream stream = read(fixture);
    final Map<Node, Object> objects = Maps.newLinkedHashMap();

    if (stream == null) {
        throw new IllegalArgumentException("No such fixture found: " + fixture);
    }//ww  w  . j a v a 2s . c om

    final Constructor ctor = new Constructor() {
        {
            yamlClassConstructors.put(NodeId.scalar, new TimeStampConstruct());
        }

        class TimeStampConstruct extends Constructor.ConstructScalar {

            Construct dateConstructor = yamlConstructors.get(Tag.TIMESTAMP);

            @Override
            public Object construct(Node nnode) {
                if (nnode.getTag().equals(Tag.TIMESTAMP)) {
                    Date date = (Date) dateConstructor.construct(nnode);
                    if (nnode.getType() == LocalDate.class) {
                        return new LocalDate(date, DateTimeZone.UTC);
                    }
                    if (nnode.getType() == LocalDateTime.class) {
                        return new LocalDateTime(date, DateTimeZone.UTC);
                    }
                    return new DateTime(date, DateTimeZone.UTC);
                } else {
                    return super.construct(nnode);
                }
            }

        }

        @Override
        protected Object constructObject(Node node) {

            Object obj = super.constructObject(node);

            if (objects.containsKey(node)) {
                return objects.get(node);
            }

            if (obj instanceof Model) {
                objects.put(node, obj);
                return obj;
            }
            return obj;
        }
    };

    for (Class<?> klass : JPA.models()) {
        ctor.addTypeDescription(new TypeDescription(klass, "!" + klass.getSimpleName() + ":"));
    }

    Yaml data = new Yaml(ctor);
    data.load(stream);

    for (Object item : Lists.reverse(Lists.newArrayList(objects.values()))) {
        try {
            JPA.manage((Model) item);
        } catch (Exception e) {
        }
    }
}

From source file:com.baidubce.services.lss.LssClient.java

License:Open Source License

/**
 * Get your live session with token by live session id.
 *
 * @param sessionId  Live session id.//w  w w. j a  v a2  s.c  om
 * @param timeoutInMinute  Timeout of token.
 *
 * @return Your live session with token.
 */
public GetSessionResponse getSessionWithToken(String sessionId, Integer timeoutInMinute) {
    GetSessionResponse getSessionResponse = getSession(sessionId);
    if (timeoutInMinute == null) {
        return getSessionResponse;
    }
    DateTime dateTime = new DateTime(DateTimeZone.UTC);
    DateTime expireTime = dateTime.plusMinutes(timeoutInMinute);
    DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'");
    String expire = formatter.print(expireTime);

    GetSecurityPolicyResponse getSecurityPolicyResponse = getSecurityPolicy(
            getSessionResponse.getSecurityPolicy());
    if (getSecurityPolicyResponse.getAuth().getPlay()) {
        String hlsUrl = getSessionResponse.getPlay().getHlsUrl();
        String rtmpUrl = getSessionResponse.getPlay().getRtmpUrl();
        if (hlsUrl != null) {
            String hlsToken = LssUtils.hmacSha256(String.format("/%s/live.m3u8;%s", sessionId, expire),
                    getSecurityPolicyResponse.getAuth().getKey());
            if (hlsUrl.lastIndexOf('?') == -1) {
                hlsUrl += String.format("?token=%s&expire=%s", hlsToken, expire);
            } else {
                hlsUrl += String.format("&token=%s&expire=%s", hlsToken, expire);
            }
            getSessionResponse.getPlay().setHlsUrl(hlsUrl);
        }
        if (rtmpUrl != null) {
            String rtmpToken = LssUtils.hmacSha256(String.format("%s;%s", sessionId, expire),
                    getSecurityPolicyResponse.getAuth().getKey());
            rtmpUrl += String.format("?token=%s&expire=%s", rtmpToken, expire);
            getSessionResponse.getPlay().setRtmpUrl(rtmpUrl);
        }
    }

    if (getSecurityPolicyResponse.getAuth().getPush()) {
        String pushUrl = getSessionResponse.getPublish().getPushUrl();
        String pushToken = LssUtils.hmacSha256(
                String.format("%s;%s", getSessionResponse.getPublish().getPushStream(), expire),
                getSecurityPolicyResponse.getAuth().getKey());
        pushUrl += String.format("?token=%s&expire=%s", pushToken, expire);
        getSessionResponse.getPublish().setPushUrl(pushUrl);
    }
    return getSessionResponse;
}

From source file:com.barchart.feed.base.values.provider.BaseTime.java

License:BSD License

@Override
public final DateTime asDateTime() {
    return new DateTime(asMillisUTC(), DateTimeZone.UTC);
}

From source file:com.barchart.feed.ddf.message.enums.DDF_TradeDay.java

License:BSD License

/**
 * From millis utc./*ww w  .jav a  2 s .com*/
 *
 * @param millisUTC the millis utc
 * @return the dD f_ trade day
 */
public static final DDF_TradeDay fromMillisUTC(final long millisUTC) {
    final DateTime dateTime = new DateTime(millisUTC, DateTimeZone.UTC);
    return fromDay(dateTime.getDayOfMonth());
}