List of usage examples for org.joda.time DateTimeZone forID
@FromString public static DateTimeZone forID(String id)
From source file:com.barchart.feed.base.instrument.enums.MarketDisplay.java
License:BSD License
/** in instrument time zone */ public static final String timeTextShort(final TimeValue value, final MarketInstrument instrument) { final TextValue name = instrument.get(InstrumentField.TIME_ZONE); final DateTimeZone zone = DateTimeZone.forID(name.toString()); return TIME_SHORT.print(value.asDateTime(zone)); }
From source file:com.barchart.feed.ddf.historical.provider.CodecHelper.java
License:BSD License
/** * http://ds01.ddfplus.com/historical/queryticks.ashx?username=USER&password * = PASS&symbol=GOOG&start=20100601090000&end=201006020900000 * *///from w w w. j a v a 2 s .c o m final static String urlQuery(final DDF_Settings settings, final DDF_Query<?> query) { final StringBuilder text = new StringBuilder(256); final CharSequence server = ConstHistorical.historicalServer(settings); final CharSequence queryPage = query.type.queryPage; final CharSequence username = settings.getAuthUser(); final CharSequence password = settings.getAuthPass(); final Instrument instrument = query.instrument; final CharSequence symbol = instrument.vendorSymbols().get(VendorID.BARCHART_HISTORICAL); final DateTimeZone timeZone = DateTimeZone.forID(instrument.timeZoneName()); final CharSequence start = requestTime(query.timeStart, timeZone); final CharSequence end = requestTime(query.timeEnd, timeZone); final CharSequence maxRecords = query.maxRecords <= 0 ? "" : "" + query.maxRecords; final DDF_QueryOrder resultOrder = query.resultOrder; final CharSequence order = resultOrder == null ? ASCENDING.code : resultOrder.code; final CharSequence interval = query.groupBy <= 1 ? "1" : "" + query.groupBy; final DDF_QueryEodType eodType = query.eodType; final CharSequence data = eodType == null ? "" : eodType.code; final DDF_QueryEodVolume eodVolume = query.eodVolume; final CharSequence volume = eodVolume == null ? "" : eodVolume.code; text.append(server); if (server.charAt(server.length() - 1) != '/') { text.append("/"); } text.append(queryPage); text.append("?"); text.append("username="); text.append(username); text.append("&"); text.append("password="); text.append(password); text.append("&"); text.append("symbol="); text.append(symbol); text.append("&"); text.append("start="); text.append(start); text.append("&"); text.append("end="); text.append(end); text.append("&"); text.append("maxrecords="); text.append(maxRecords); text.append("&"); text.append("order="); text.append(order); // if (query.type.isIn(MINUTES, MINUTES_NEARBY, MINUTES_FORM_T, MINUTES_TREND)) { text.append("&"); text.append("interval="); text.append(interval); } if (query.type.isIn(TICKS_FORM_T)) { text.append("&"); text.append("sessionfilter=%2Bt"); // text.append(sessionFilter); } // if (query.type.isIn(END_OF_DAY)) { text.append("&"); text.append("data="); text.append(data); // if (query.instrument.get(DDF_InstrumentField.DDF_EXCHANGE).kind // == DDF_ExchangeKind.FUTURE) { // } // equities now support sum text.append("&"); text.append("volume="); text.append(volume); if (query.backadjust) { text.append("&backadjust=true"); } if (query.daystoexpiration > 0) { text.append("&daystoexpiration=" + query.daystoexpiration); } } if (query.type.isIn(TICKS_TREND, MINUTES_TREND, END_OF_DAY_TREND)) { text.append("&"); text.append("trend="); text.append("y"); } return text.toString(); }
From source file:com.barchart.feed.ddf.historical.provider.CodecHelper.java
License:BSD License
static long decodeTime(final String string, final Instrument instrument, final DateTimeFormatter format) { final DateTimeZone zone = DateTimeZone.forID(instrument.timeZoneName()); return format.withZone(zone).parseMillis(string); }
From source file:com.barchart.feed.ddf.historical.provider.CodecHelper.java
License:BSD License
static String encodeTime(final long millisUTC, final Instrument instrument, final DateTimeFormatter format) { final DateTimeZone zone = DateTimeZone.forID(instrument.timeZoneName()); return format.withZone(zone).print(millisUTC); }
From source file:com.barchart.feed.ddf.message.provider.BaseMarket.java
License:BSD License
protected void decodeTail(final ByteBuffer buffer) { DateTimeZone zone;//from ww w .j av a 2 s.c om if (getInstrument().timeZoneName() == null || "Null Time Zone".equals(getInstrument().timeZoneName())) { zone = getExchange().kind.time.zone; } else { zone = DateTimeZone.forID(getInstrument().timeZoneName()); } // final byte dayCode = buffer.get(); // <day> final byte sessCode = buffer.get(); // <session> check(buffer.get(), ETX); // <etx> millisUTC = decodeFeedTimeStamp(zone, buffer); // <time stamp> // ordTradeDay = DDF_TradeDay.fromCode(dayCode).ord; ordSession = DDF_Session.fromPair(ordExchange, sessCode).ord; }
From source file:com.battlelancer.seriesguide.util.TimeTools.java
License:Apache License
/** * Returns the appropriate time zone for the given tzdata zone identifier. * * <p> Falls back to "America/New_York" if timezone string is empty or unknown. *//*from ww w .j av a 2s. c o m*/ public static DateTimeZone getDateTimeZone(@Nullable String timezone) { if (timezone != null && timezone.length() != 0) { try { return DateTimeZone.forID(timezone); } catch (IllegalArgumentException ignored) { } } return DateTimeZone.forID(TIMEZONE_ID_US_EASTERN); }
From source file:com.battlelancer.seriesguide.util.TimeTools.java
License:Apache License
private static DateTime applyUnitedStatesCorrections(@Nullable String country, @NonNull String localTimeZone, @NonNull DateTime dateTime) {//from www .j a va 2 s. co m // assumed base time zone for US shows by trakt is America/New_York // EST UTC5:00, EDT UTC4:00 // east feed (default): simultaneously in Eastern and Central // delayed 1 hour in Mountain // delayed three hours in Pacific // <==> // same local time in Eastern + Pacific (e.g. 20:00) // same local time in Central + Mountain (e.g. 19:00) // not a US show or no correction necessary (getting east feed) if (!ISO3166_1_UNITED_STATES.equals(country) || localTimeZone.equals(TIMEZONE_ID_US_EASTERN) || localTimeZone.equals(TIMEZONE_ID_US_EASTERN_DETROIT) || localTimeZone.equals(TIMEZONE_ID_US_CENTRAL)) { return dateTime; } int offset = 0; if (localTimeZone.equals(TIMEZONE_ID_US_MOUNTAIN)) { // MST UTC7:00, MDT UTC6:00 offset += 1; } else if (localTimeZone.equals(TIMEZONE_ID_US_ARIZONA)) { // is always UTC-07:00, so like Mountain, but no DST boolean noDstInEastern = DateTimeZone.forID(TIMEZONE_ID_US_EASTERN) .isStandardOffset(dateTime.getMillis()); if (noDstInEastern) { offset += 1; } else { offset += 2; } } else if (localTimeZone.equals(TIMEZONE_ID_US_PACIFIC)) { // PST UTC8:00 or PDT UTC7:00 offset += 3; } dateTime = dateTime.plusHours(offset); return dateTime; }
From source file:com.cedarsoft.serialization.serializers.jackson.DateTimeZoneSerializer.java
License:Open Source License
@Nonnull @Override/* ww w . j a v a2 s. co m*/ public DateTimeZone deserialize(@Nonnull JsonParser deserializeFrom, @Nonnull Version formatVersion) throws VersionException, IOException, JsonProcessingException { verifyVersionReadable(formatVersion); String id = deserializeFrom.getText(); //Constructing the deserialized object return DateTimeZone.forID(id); }
From source file:com.cedarsoft.serialization.serializers.stax.mate.ZoneInfoSerializer.java
License:Open Source License
@Nonnull @Override public DateTimeZone deserialize(@Nonnull InputStream in) throws IOException, VersionException { return DateTimeZone.forID(IOUtils.toString(in)); }
From source file:com.citrix.g2w.webdriver.pages.BasePage.java
License:Open Source License
/** * Method to get aged date time.//from ww w . j a va 2 s . com * * @param dateTime * (date time) * @return agedDateTime */ public DateTime getAgedDateTime(final DateTime dateTime) { DateTimeZone californiaTimeZone = DateTimeZone.forID(this.propertyUtil.getProperty("environment.timezone")); DateTime agedDateTime = this.getGMTDateTime(dateTime); agedDateTime = new DateTime(agedDateTime, californiaTimeZone); return agedDateTime; }