List of usage examples for java.util TimeZone getDefault
public static TimeZone getDefault()
From source file:fr.itinerennes.bundler.gtfs.GtfsAdvancedDao.java
public Iterable<ServiceDate> getAllServiceDates() { final ServiceDate start = getStartDate(); final ServiceDate end = getEndDate(); return new Iterable<ServiceDate>() { @Override/*ww w. j a v a 2 s .co m*/ public Iterator<ServiceDate> iterator() { return new Iterator<ServiceDate>() { private ServiceDate next = start; @Override public boolean hasNext() { return next.compareTo(end) <= 0; } @Override public ServiceDate next() { final ServiceDate current = next; next = next.next(TimeZone.getDefault()); return current; } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; }
From source file:com.adaptris.core.services.metadata.DateFormatBuilder.java
private DateFormatter withTimeZone(SimpleDateFormat format, String id) { format.setTimeZone((!isBlank(id)) ? TimeZone.getTimeZone(id) : TimeZone.getDefault()); return new SimpleDateFormatter(format); }
From source file:org.emfjson.jackson.module.EMFModule.java
/** * Returns a pre configured mapper with the EMF module. * * @return mapper/* w w w . j a v a2s . c o m*/ */ public static ObjectMapper setupDefaultMapper() { final ObjectMapper mapper = new ObjectMapper(); // same as emf final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH); dateFormat.setTimeZone(TimeZone.getDefault()); mapper.configure(SerializationFeature.INDENT_OUTPUT, true); mapper.setDateFormat(dateFormat); mapper.setTimeZone(TimeZone.getDefault()); mapper.registerModule(new EMFModule()); return mapper; }
From source file:com.facebook.presto.jdbc.PrestoConnection.java
PrestoConnection(URI uri, String user, QueryExecutor queryExecutor) throws SQLException { this.uri = checkNotNull(uri, "uri is null"); this.address = HostAndPort.fromParts(uri.getHost(), uri.getPort()); this.user = checkNotNull(user, "user is null"); this.queryExecutor = checkNotNull(queryExecutor, "queryExecutor is null"); catalog.set("default"); schema.set("default"); timeZoneId.set(TimeZone.getDefault().getID()); locale.set(Locale.getDefault()); if (!isNullOrEmpty(uri.getPath())) { setCatalogAndSchema();/*from www . j a v a 2s . c o m*/ } }
From source file:org.jstockchart.dataset.TimeseriesDataset.java
/** * Creates a new <code>TimeseriesDataset</code> instance. * /*www. jav a 2 s. c om*/ * @param priceName * the price chart name. * @param averageName * the average chart name. * @param volumeName * the volume chart name. * @param timePeriodClass * the <code>TimePeriod</code> class. * @param step * the step of the time period. * @param timeline * a "segmented" timeline. * @param timeZone * the time zone. * @param createAverage * indicates whether or not the average chart should be created. */ public TimeseriesDataset(String priceName, String averageName, String volumeName, Class<? extends TimePeriod> timePeriodClass, int step, SegmentedTimeline timeline, TimeZone timeZone, boolean createAverage) { priceTimeSeries = new SegmentedTimeSeries(priceName, step, timeline); averageTimeSeries = new SegmentedTimeSeries(averageName, step, timeline); volumeTimeSeries = new TimeSeries(volumeName); this.timePeriodClass = timePeriodClass; if (timeZone != null) { this.timeZone = timeZone; } else { this.timeZone = TimeZone.getDefault(); } if (createAverage) { average = new Average(); } }
From source file:gov.nih.nci.cabig.caaers.service.migrator.adverseevent.AdverseEventConverter.java
public AdverseEvent convert(AdverseEventType adverseEventDto) { AdverseEvent adverseEvent = new AdverseEvent(); if (adverseEventDto.getVerbatim() != null) { adverseEvent.setDetailsForOther(adverseEventDto.getVerbatim()); }/* w ww .java 2 s .co m*/ adverseEvent.setExternalId(adverseEventDto.getExternalId()); populateHospitalization(adverseEventDto, adverseEvent); populateGrade(adverseEventDto, adverseEvent); adverseEvent.setExpected(adverseEventDto.isExpected()); populateAttributionSummary(adverseEventDto, adverseEvent); adverseEvent.setComments(adverseEventDto.getComments()); adverseEvent.setReporterEmail(adverseEventDto.getReporterEmail()); if (adverseEventDto.getStartDate() != null) adverseEvent.setStartDate(adverseEventDto.getStartDate().toGregorianCalendar().getTime()); if (adverseEventDto.getEndDate() != null) adverseEvent.setEndDate(adverseEventDto.getEndDate().toGregorianCalendar().getTime()); if (adverseEventDto.getDateFirstLearned() != null) { // Convert the timezone Server timezone but user can send it any timezone. TimeZone timeZone = TimeZone.getDefault(); adverseEventDto.getDateFirstLearned().toGregorianCalendar().setTimeZone(timeZone); adverseEvent.setGradedDate(adverseEventDto.getDateFirstLearned().toGregorianCalendar().getTime()); } if (adverseEventDto.getAdverseEventCtepTerm() != null) { adverseEvent.setOtherSpecify(adverseEventDto.getAdverseEventCtepTerm().getOtherSpecify()); } if (adverseEventDto.getAdverseEventCtepTerm() != null && adverseEventDto.getAdverseEventCtepTerm().getCtepCode() != null) { AdverseEventCtcTerm ctcTerm = new AdverseEventCtcTerm(); adverseEvent.setAdverseEventCtcTerm(ctcTerm); ctcTerm.setCtcTerm(new CtcTerm()); ctcTerm.getCtcTerm().setCtepCode(adverseEventDto.getAdverseEventCtepTerm().getCtepCode()); ctcTerm.getCtcTerm() .setOtherRequired(adverseEventDto.getAdverseEventCtepTerm().getOtherSpecify() != null); if (adverseEventDto.getAdverseEventCtepTerm().getOtherMeddra() != null) { LowLevelTerm lowLevelTerm = new LowLevelTerm(); lowLevelTerm .setMeddraCode(adverseEventDto.getAdverseEventCtepTerm().getOtherMeddra().getMeddraCode()); // lowLevelTerm.setMeddraTerm(adverseEventDto.getAdverseEventCtepTerm().getOtherMeddra().getMeddraTerm()); adverseEvent.setMeddraTerm(lowLevelTerm); adverseEvent.setLowLevelTerm(lowLevelTerm); } } if (adverseEventDto.getAdverseEventMeddraLowLevelTerm() != null && adverseEventDto.getAdverseEventMeddraLowLevelTerm().getMeddraCode() != null) { LowLevelTerm lowLevelTerm = new LowLevelTerm(); lowLevelTerm.setMeddraCode(adverseEventDto.getAdverseEventMeddraLowLevelTerm().getMeddraCode()); // lowLevelTerm.setMeddraTerm(adverseEventDto.getAdverseEventMeddraLowLevelTerm().getMeddraTerm()); AdverseEventMeddraLowLevelTerm aeMeddraLowLevelTerm = new AdverseEventMeddraLowLevelTerm(); aeMeddraLowLevelTerm.setTerm(lowLevelTerm); adverseEvent.setAdverseEventMeddraLowLevelTerm(aeMeddraLowLevelTerm); } if (adverseEventDto.getEventApproximateTime() != null) { TimeValue tv = new TimeValue(); tv.setHour(adverseEventDto.getEventApproximateTime().getHour().intValue()); tv.setMinute(adverseEventDto.getEventApproximateTime().getMinute().intValue()); if (adverseEventDto.getEventApproximateTime().getAmpm().equals("AM")) { tv.setType(0); } else { tv.setType(1); } adverseEvent.setEventApproximateTime(tv); } if (adverseEventDto.getEventLocation() != null) { adverseEvent.setEventLocation(adverseEventDto.getEventLocation()); } if (adverseEventDto.getOutcome() != null) { populateOutcomes(adverseEventDto, adverseEvent); } if (adverseEventDto.getHospitalization() != null && adverseEventDto.getHospitalization().equals(HospitalizationType.YES)) { Outcome hOutcome = new Outcome(); hOutcome.setOutcomeType(gov.nih.nci.cabig.caaers.domain.OutcomeType.HOSPITALIZATION); adverseEvent.addOutComeIfNecessary(hOutcome); } if (adverseEventDto.isIncreasedRisk() != null) { adverseEvent.setParticipantAtRisk(adverseEventDto.isIncreasedRisk()); } populateOutcomes(adverseEventDto, adverseEvent); return adverseEvent; }
From source file:at.alladin.rmbt.controlServer.ResultUpdateResource.java
@Post("json") public String request(final String entity) { addAllowOrigin();// w w w .ja va 2 s . c om JSONObject request = null; final ErrorList errorList = new ErrorList(); final JSONObject answer = new JSONObject(); final String ip = getIP(); System.out.println(MessageFormat.format(labels.getString("NEW_RESULT_UPDATE"), ip)); if (entity != null && !entity.isEmpty()) { try { request = new JSONObject(entity); final UUID clientUUID = UUID.fromString(request.getString("uuid")); final UUID testUUID = UUID.fromString(request.getString("test_uuid")); final int zipCode = request.optInt("zip_code", 0); final double geoLat = request.optDouble("geo_lat", Double.NaN); final double geoLong = request.optDouble("geo_long", Double.NaN); final float geoAccuracy = (float) request.optDouble("accuracy", 0); final String provider = request.optString("provider").toLowerCase(); final Client client = new Client(conn); final long clientId = client.getClientByUuid(clientUUID); if (clientId < 0) throw new IllegalArgumentException("error while loading client"); final Test test = new Test(conn); if (test.getTestByUuid(testUUID) < 0) throw new IllegalArgumentException("error while loading test"); if (test.getField("client_id").longValue() != clientId) throw new IllegalArgumentException("client UUID does not match test"); if (zipCode > 0) { ((IntField) test.getField("zip_code")).setValue(zipCode); } if (!Double.isNaN(geoLat) && !Double.isNaN(geoLong) && (provider.equals(GEO_PROVIDER_GEOCODER) || provider.equals(GEO_PROVIDER_MANUAL))) { final GeoLocation geoloc = new GeoLocation(conn); geoloc.setTest_id(test.getUid()); final Timestamp tstamp = java.sql.Timestamp .valueOf(new Timestamp((new Date().getTime())).toString()); geoloc.setTime(tstamp, TimeZone.getDefault().toString()); geoloc.setAccuracy(geoAccuracy); geoloc.setGeo_lat(geoLat); geoloc.setGeo_long(geoLong); geoloc.setProvider(provider); geoloc.storeLocation(); ((DoubleField) test.getField("geo_lat")).setValue(geoLat); ((DoubleField) test.getField("geo_long")).setValue(geoLong); ((DoubleField) test.getField("geo_accuracy")).setValue(geoAccuracy); test.getField("geo_provider").setString(provider); } test.storeTestResults(true); if (test.hasError()) errorList.addError(test.getError()); } catch (final JSONException e) { errorList.addError("ERROR_REQUEST_JSON"); System.out.println("Error parsing JSDON Data " + e.toString()); } catch (final IllegalArgumentException e) { errorList.addError("ERROR_REQUEST_JSON"); System.out.println("Error parsing JSDON Data " + e.toString()); } } return answer.toString(); }
From source file:com.liferay.ide.server.remote.AbstractRemoteServerPublisher.java
protected void addToZip(IPath path, IResource resource, ZipOutputStream zip, boolean adjustGMTOffset) throws IOException, CoreException { switch (resource.getType()) { case IResource.FILE: ZipEntry zipEntry = new ZipEntry(path.toString()); zip.putNextEntry(zipEntry);/*from w ww . ja va2 s. c om*/ InputStream contents = ((IFile) resource).getContents(); if (adjustGMTOffset) { TimeZone currentTimeZone = TimeZone.getDefault(); Calendar currentDt = new GregorianCalendar(currentTimeZone, Locale.getDefault()); // Get the Offset from GMT taking current TZ into account int gmtOffset = currentTimeZone.getOffset(currentDt.get(Calendar.ERA), currentDt.get(Calendar.YEAR), currentDt.get(Calendar.MONTH), currentDt.get(Calendar.DAY_OF_MONTH), currentDt.get(Calendar.DAY_OF_WEEK), currentDt.get(Calendar.MILLISECOND)); zipEntry.setTime(System.currentTimeMillis() + (gmtOffset * -1)); } try { IOUtils.copy(contents, zip); } finally { contents.close(); } break; case IResource.FOLDER: case IResource.PROJECT: IContainer container = (IContainer) resource; IResource[] members = container.members(); for (IResource res : members) { addToZip(path.append(res.getName()), res, zip, adjustGMTOffset); } } }
From source file:org.onebusaway.webapp.actions.where.ScheduleAction.java
@Override @Actions({ @Action(value = "/where/standard/schedule") }) public String execute() throws Exception { if (_date == null) _date = new Date(); if (_id == null) return INPUT; _result = _service.getScheduleForStop(_id, _date); if (_result == null) throw new NoSuchStopServiceException(_id); StopCalendarDaysBean days = _result.getCalendarDays(); String tzName = days.getTimeZone(); _timeZone = TimeZone.getTimeZone(tzName); if (_timeZone == null) _timeZone = TimeZone.getDefault(); filterResults();/*from ww w .j av a 2s.c om*/ return SUCCESS; }
From source file:com.opengamma.integration.tool.marketdata.MarketDataSnapshotToolUtils.java
private static void printVersionListQuery(SnapshotUtils snapshotUtils, String optionValue) { DateTimeFormatter dateTimeFormatter = new DateTimeFormatterBuilder() .appendValue(YEAR, 4, 10, SignStyle.EXCEEDS_PAD).appendLiteral('-').appendValue(MONTH_OF_YEAR, 2) .appendLiteral('-').appendValue(DAY_OF_MONTH, 2).appendValue(HOUR_OF_DAY, 2).appendLiteral(':') .appendValue(MINUTE_OF_HOUR, 2).optionalStart().appendLiteral(':').appendValue(SECOND_OF_MINUTE, 2) .appendOffsetId().toFormatter(); List<VersionInfo> snapshotVersions = snapshotUtils.snapshotVersionsByName(optionValue); System.out.println(OffsetDateTime.now().toString(dateTimeFormatter)); int fieldWidth = OffsetDateTime.now().toString(dateTimeFormatter).length(); // Assumes all offset date times have same width header(fieldWidth);/*ww w . ja v a 2 s. c o m*/ String id = TimeZone.getDefault().getID(); for (VersionInfo versionInfo : snapshotVersions) { OffsetDateTime versionFrom = versionInfo.getVersionFrom() != null ? OffsetDateTime.ofInstant(versionInfo.getVersionFrom(), ZoneId.of(id)) : null; OffsetDateTime versionTo = versionInfo.getVersionTo() != null ? OffsetDateTime.ofInstant(versionInfo.getVersionTo(), ZoneId.of(id)) : null; OffsetDateTime correctionFrom = versionInfo.getCorrectionFrom() != null ? OffsetDateTime.ofInstant(versionInfo.getCorrectionFrom(), ZoneId.of(id)) : null; OffsetDateTime correctionTo = versionInfo.getCorrectionTo() != null ? OffsetDateTime.ofInstant(versionInfo.getCorrectionTo(), ZoneId.of(id)) : null; if (versionFrom != null) { System.out.print(versionFrom.toString(dateTimeFormatter)); } else { notSpecified(fieldWidth); } spaces(); if (versionTo != null) { System.out.print(versionTo.toString(dateTimeFormatter)); } else { notSpecified(fieldWidth); } spaces(); if (correctionFrom != null) { System.out.print(correctionFrom.toString(dateTimeFormatter)); } else { notSpecified(fieldWidth); } spaces(); if (correctionTo != null) { System.out.print(correctionTo.toString(dateTimeFormatter)); } else { notSpecified(fieldWidth); } spaces(); System.out.println(versionInfo.getUniqueId()); } }