List of usage examples for org.joda.time Instant toString
@ToString
public String toString()
From source file:InstantTypeAdapter.java
License:Apache License
@Override public void write(JsonWriter out, Instant value) throws IOException { if (value == null) { out.nullValue();//from ww w . ja va 2s . c o m } else { out.value(value.toString()); } }
From source file:com.jbirdvegas.mgerrit.search.AfterSearch.java
License:Apache License
@Override public String toString() { Instant instant = getInstant(); if (instant == null) { instant = AgeSearch.getInstantFromPeriod(getPeriod()); }/*from ww w . j a va 2 s . c o m*/ return OP_NAME + ":" + instant.toString(); }
From source file:com.netflix.metacat.main.services.search.ElasticSearchUtilImpl.java
License:Apache License
/** * Search the names by names and by the given marker. * @param type type//from ww w. ja va 2 s . c o m * @param qualifiedNames names * @param marker marker * @param excludeQualifiedNames exclude names * @param valueType dto type * @param <T> dto type * @return dto */ public <T> List<T> getQualifiedNamesByMarkerByNames(final String type, final List<QualifiedName> qualifiedNames, final Instant marker, final List<QualifiedName> excludeQualifiedNames, final Class<T> valueType) { final List<T> result = Lists.newArrayList(); final List<String> names = qualifiedNames.stream().map(QualifiedName::toString) .collect(Collectors.toList()); final List<String> excludeNames = excludeQualifiedNames.stream().map(QualifiedName::toString) .collect(Collectors.toList()); // // Run the query and get the response. final QueryBuilder queryBuilder = QueryBuilders.boolQuery() .must(QueryBuilders.termsQuery("name.qualifiedName.tree", names)) .must(QueryBuilders.termQuery("deleted_", false)) .must(QueryBuilders.rangeQuery("_timestamp").lte(marker.toDate())) .mustNot(QueryBuilders.termsQuery("name.qualifiedName.tree", excludeNames)) .mustNot(QueryBuilders.termQuery("refreshMarker_", marker.toString())); final SearchRequestBuilder request = client.prepareSearch(esIndex).setTypes(type) .setSearchType(SearchType.QUERY_THEN_FETCH).setQuery(queryBuilder).setSize(Integer.MAX_VALUE); final SearchResponse response = request.execute().actionGet(); if (response.getHits().hits().length != 0) { result.addAll(parseResponse(response, valueType)); } return result; }
From source file:com.terry.PubSubPipeLine.java
License:Apache License
public static void main(String[] args) { PipelineOptions option = PipelineOptionsFactory.fromArgs(args).withValidation().create(); Pipeline p = Pipeline.create(option); p.apply(PubsubIO.Read.named("ReadFromPubSub").topic("projects/terrycho-sandbox/topics/dataflow") .timestampLabel("mytimestamp").idLabel("myid")).apply(ParDo.of(new DoFn<String, String>() { @Override/*from ww w . j a v a 2 s. c om*/ public void processElement(ProcessContext c) { c.output(c.element().toUpperCase()); } })).apply(ParDo.of(new DoFn<String, Void>() { @Override public void processElement(ProcessContext c) { org.joda.time.Instant timeStamp = c.timestamp(); LOG.info("timestamp :" + timeStamp.toString() + ":" + c.element()); } })); p.run(); }
From source file:org.apache.beam.sdk.transforms.windowing.BoundedWindow.java
License:Apache License
/** * Formats a {@link Instant} timestamp with additional Beam-specific metadata, such as indicating * whether the timestamp is the end of the global window or one of the distinguished values {@link * #TIMESTAMP_MIN_VALUE} or {@link #TIMESTAMP_MIN_VALUE}. */// w w w . j av a 2 s . co m public static String formatTimestamp(Instant timestamp) { if (timestamp.equals(TIMESTAMP_MIN_VALUE)) { return timestamp.toString() + " (TIMESTAMP_MIN_VALUE)"; } else if (timestamp.equals(TIMESTAMP_MAX_VALUE)) { return timestamp.toString() + " (TIMESTAMP_MAX_VALUE)"; } else if (timestamp.equals(GlobalWindow.INSTANCE.maxTimestamp())) { return timestamp.toString() + " (end of global window)"; } else { return timestamp.toString(); } }
From source file:org.esco.portlet.changeetab.service.impl.CachingEtablissementService.java
License:Apache License
/** Laod the etablissement cache. */ protected synchronized void forceLoadEtablissementCache() { // Test if another concurrent thread just didn't already load the cache if (this.cacheLoadingNeeded()) { CachingEtablissementService.LOG.debug("Loading etablissement cache..."); this.loadingInProgress = true; final Collection<Etablissement> allEtabs = this.etablissementDao.findAllEtablissements(); if (allEtabs != null && allEtabs.size() > 0) { // Aquire write lock to avoid cache unconsistency this.cacheWl.lock(); try { this.etablissementCache.clear(); final Instant refreshedInstant = new Instant().plus(this.cachingDuration); for (final Etablissement etab : allEtabs) { final String etabCacheKey = this.genCacheKey(etab.getCode()); this.etablissementCache.put(etabCacheKey, etab); }/*w w w. j av a 2 s. c om*/ this.expiringInstant = refreshedInstant; CachingEtablissementService.LOG.debug("Etablissement cache loaded with new expiration time: {}", refreshedInstant.toString()); } finally { this.cacheWl.unlock(); this.loadingInProgress = false; } } } }
From source file:org.jadira.usertype.dateandtime.joda.columnmapper.BigIntegerColumnInstantMapper.java
License:Apache License
@Override public String toNonNullString(Instant value) { return value.toString(); }
From source file:org.joda.example.time.Examples.java
License:Apache License
private void runInstant() { System.out.println("Instant"); System.out.println("======="); System.out//from ww w . j a v a2s. c o m .println("Instant stores a point in the datetime continuum as millisecs from 1970-01-01T00:00:00Z"); System.out.println("Instant is immutable and thread-safe"); System.out.println(" in = new Instant()"); Instant in = new Instant(); System.out.println("Millisecond time: in.getMillis(): " + in.getMillis()); System.out.println("ISO string version: in.toString(): " + in.toString()); System.out.println("ISO chronology: in.getChronology(): " + in.getChronology()); System.out.println("UTC time zone: in.getDateTimeZone(): " + in.getZone()); System.out.println("Change millis: in.withMillis(0): " + in.withMillis(0L)); System.out.println(""); System.out.println("Convert to Instant: in.toInstant(): " + in.toInstant()); System.out.println("Convert to DateTime: in.toDateTime(): " + in.toDateTime()); System.out.println("Convert to MutableDT: in.toMutableDateTime(): " + in.toMutableDateTime()); System.out.println("Convert to Date: in.toDate(): " + in.toDate()); System.out.println(""); System.out.println(" in2 = new Instant(in.getMillis() + 10)"); Instant in2 = new Instant(in.getMillis() + 10); System.out.println("Equals ms and chrono: in.equals(in2): " + in.equals(in2)); System.out.println("Compare millisecond: in.compareTo(in2): " + in.compareTo(in2)); System.out.println("Compare millisecond: in.isEqual(in2): " + in.isEqual(in2)); System.out.println("Compare millisecond: in.isAfter(in2): " + in.isAfter(in2)); System.out.println("Compare millisecond: in.isBefore(in2): " + in.isBefore(in2)); }
From source file:org.powertac.common.Rate.java
License:Apache License
/** * Allows initial publication of HourlyCharge instances within the notification interval. *//*from w w w . j a v a2s . c o m*/ @StateChange public boolean addHourlyCharge(HourlyCharge newCharge, boolean publish) { boolean result = false; if (fixed) { // cannot change this rate log.error("Cannot change Rate " + this.toString()); } else { Instant now = getCurrentTime(); double sgn = Math.signum(maxValue); long warning = newCharge.getAtTime().getMillis() - now.getMillis(); if (warning < noticeInterval * TimeService.HOUR && !publish) { // too late log.warn( "Too late (" + now.toString() + ") to change rate for " + newCharge.getAtTime().toString()); } else if (sgn * newCharge.getValue() > sgn * maxValue) { // charge too high log.warn("Excess charge: " + newCharge.getValue() + " > " + maxValue); } else if (sgn * newCharge.getValue() < sgn * minValue) { // charge too low log.warn("Charge too low: " + newCharge.getValue() + " < " + minValue); } else { if (probe == null) { probe = new ProbeCharge(new Instant(0l), 0.0); } // first, remove the existing charge for the specified time probe.setAtTime(newCharge.getAtTime().plus(1000l)); //HourlyCharge probe = new HourlyCharge(newCharge.getAtTime().plus(1000l), 0); SortedSet<HourlyCharge> head = rateHistory.headSet(probe); if (head != null && head.size() > 0) { HourlyCharge item = head.last(); if (item.getAtTime() == newCharge.getAtTime()) { log.debug("remove " + item.toString()); rateHistory.remove(item); } } newCharge.setRateId(getId()); rateHistory.add(newCharge); log.info("Adding HourlyCharge " + newCharge.getId() + " at " + newCharge.getAtTime() + " to " + this.toString()); result = true; } } return result; }
From source file:org.powertac.common.repo.TimeslotRepo.java
License:Apache License
/** * Creates a timeslot with the given start time. The sequence number of the * timeslot is the number of timeslots since the simulation base time. *///from w ww.j ava2 s. c o m public Timeslot makeTimeslot(Instant startTime) { long duration = Competition.currentCompetition().getTimeslotDuration(); Instant base = Competition.currentCompetition().getSimulationBaseTime(); int index = (int) ((startTime.getMillis() - base.getMillis()) / duration); if (index < 0) log.error("makeTimeslot(" + startTime.toString() + "): index=" + index + ", base=" + base); Instant realStart = getTimeForIndex(index); Timeslot result; if (index >= indexedTimeslots.size()) { // create new timeslot result = new Timeslot(index, realStart); add(result); } else { // already exists result = indexedTimeslots.get(index); } return result; }