List of usage examples for java.util TimeZone getDefault
public static TimeZone getDefault()
From source file:org.tolven.analysis.bean.PercentTimeSeriesBean.java
@Override public JFreeChart getChart(MenuStructure snapshotListMS, MenuPath snapshotPH, Long chartRange, Class<?> intervalUnitClass, String chartDataTitle, String chartTargetTitle, AccountUser accountUser, Date now) {/* w ww .j a v a 2 s. c o m*/ MenuQueryControl ctrl = new MenuQueryControl(); ctrl.setMenuStructure(snapshotListMS); ctrl.setAccountUser(accountUser); ctrl.setNow(now); ctrl.setOriginalTargetPath(snapshotPH); ctrl.setRequestedPath(snapshotPH); ctrl.setSortOrder("Date"); ctrl.setSortDirection("DESC"); ctrl.setLimit(1); List<MenuData> singleItemList = menuBean.findMenuData(ctrl); Date lastSnapshotDate = null; if (singleItemList.isEmpty()) { lastSnapshotDate = now; } else { MenuData snapshotListItem = singleItemList.get(0); MenuData snapshot = snapshotListItem.getReference(); lastSnapshotDate = new Date(snapshot.getDate01().getTime()); } RegularTimePeriod endTimePeriod = RegularTimePeriod.createInstance(intervalUnitClass, lastSnapshotDate, TimeZone.getDefault()); long milliseconds = Math.max(1, chartRange - 1) * (endTimePeriod.getEnd().getTime() - endTimePeriod.getStart().getTime()); Date fDate = new Date(endTimePeriod.getEnd().getTime() - milliseconds); RegularTimePeriod startTimePeriod = RegularTimePeriod.createInstance(intervalUnitClass, fDate, TimeZone.getDefault()); Date fromDate = startTimePeriod.getStart(); Date toDate = endTimePeriod.getEnd(); ctrl.setSortDirection("ASC"); ctrl.setLimit(0); ctrl.setFromDate(fromDate); ctrl.setToDate(toDate); List<MenuData> snapshotListItems = menuBean.findMenuData(ctrl); List<MenuData> snapshots = new ArrayList<MenuData>(); for (MenuData snapshotListItem : snapshotListItems) { snapshots.add(snapshotListItem.getReference()); } return getChart(chartDataTitle, chartTargetTitle, snapshots, fromDate, toDate, intervalUnitClass); }
From source file:DateCache.java
public DateCache(String format, DateFormatSymbols s) { _formatString = format; _dfs = s; setTimeZone(TimeZone.getDefault()); }
From source file:jamel.gui.charts.TwoSeriesScatterChart.java
/** * Sets the time range.// ww w . j a v a 2 s . c o m * * @param lower the lower date limit. * @param upper the upper date limit. */ public void setTimeRange(Date lower, Date upper) { XYSeriesCollection dataset = (XYSeriesCollection) ((XYPlot) this.getPlot()).getDataset(); // nouvelle collection de sries if (((this.begin == null) | (this.end == null)) || ((!this.begin.equals(lower)) | (!this.end.equals(upper)))) { this.begin = lower; this.end = upper; int minIndex = 0; // dfinit l'index des donnes correspondant la date de dbut try { minIndex = this.xTimeSeries.getIndex(RegularTimePeriod .createInstance(this.xTimeSeries.getTimePeriodClass(), lower, TimeZone.getDefault())); } catch (IllegalArgumentException i) { } if (minIndex < 0) minIndex = 0; // rectifie ventuellement le rsultat int maxIndex = this.xTimeSeries.getItemCount() - 1; try { maxIndex = this.xTimeSeries.getIndex(RegularTimePeriod .createInstance(this.xTimeSeries.getTimePeriodClass(), upper, TimeZone.getDefault())); } catch (IllegalArgumentException i) { } // dfinit l'index des donnes correspondant la date de fin if (maxIndex < 0) maxIndex = this.xTimeSeries.getItemCount() - 1; // rectifie ventuellement le rsultat XYSeries newSeries = new XYSeries("XY Data", false); // cre une nouvelle srie for (int index = minIndex; index <= maxIndex - 1; index++) { RegularTimePeriod currentPeriod = this.xTimeSeries.getTimePeriod(index); // rcupre la priode courante if (this.yTimeSeries.getValue(currentPeriod) != null) newSeries.add(this.xTimeSeries.getValue(currentPeriod), this.yTimeSeries.getValue(currentPeriod)); } try { dataset.removeSeries(0); } // efface la srie actuelle catch (IllegalArgumentException i) { } // au cas o il n'y aurait pas de sries enlever (la premire fois) dataset.addSeries(newSeries); } }
From source file:com.QuarkLabs.BTCeClient.adapters.OrdersAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { View v = null;/*from w ww. j a va 2s. c o m*/ TextView timestamp; final JSONObject dataToDisplay = getItem(position); TextView orderID; TextView type; TextView amount; TextView pair; TextView rate; switch (mListType) { case Transactions: if (convertView == null) { v = mInflater.inflate(R.layout.fragment_trans_history_item, parent, false); } else { v = convertView; } TextView description = (TextView) v.findViewById(R.id.TransHistoryDesc); timestamp = (TextView) v.findViewById(R.id.TransHistoryTimestamp); amount = (TextView) v.findViewById(R.id.TransHistoryAmount); try { Calendar calendar = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault()); description.setText(dataToDisplay.getString("desc")); calendar.setTimeInMillis(Long.parseLong(dataToDisplay.getString("timestamp")) * 1000L); timestamp.setText(mDateFormat.format(calendar.getTime())); amount.setText(dataToDisplay.getString("amount") + dataToDisplay.getString("currency")); } catch (JSONException e) { e.printStackTrace(); } break; case Trades: if (convertView == null) { v = mInflater.inflate(R.layout.fragment_trade_history_item, parent, false); } else { v = convertView; } pair = (TextView) v.findViewById(R.id.TradeHistoryPair); rate = (TextView) v.findViewById(R.id.TradeHistoryRate); amount = (TextView) v.findViewById(R.id.TradeHistoryAmount); type = (TextView) v.findViewById(R.id.TradeHistoryType); orderID = (TextView) v.findViewById(R.id.TradeHistoryOrderID); timestamp = (TextView) v.findViewById(R.id.TradeHistoryTimestamp); try { String pairValue = dataToDisplay.getString("pair"); Calendar calendar = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault()); orderID.setText(dataToDisplay.getString("order_id")); calendar.setTimeInMillis(Long.parseLong(dataToDisplay.getString("timestamp")) * 1000L); timestamp.setText(mDateFormat.format(calendar.getTime())); pair.setText(pairValue.replace("_", "/").toUpperCase(Locale.US)); rate.setText(dataToDisplay.getString("rate") + " " + pairValue.substring(4).toUpperCase(Locale.US)); amount.setText( dataToDisplay.getString("amount") + " " + pairValue.substring(0, 3).toUpperCase(Locale.US)); type.setText(dataToDisplay.getString("type")); } catch (JSONException e) { e.printStackTrace(); } break; case ActiveOrders: if (convertView == null) { v = mInflater.inflate(R.layout.fragment_active_orders_item, parent, false); } else { v = convertView; } pair = (TextView) v.findViewById(R.id.ActiveOrderPair); type = (TextView) v.findViewById(R.id.ActiveOrderType); amount = (TextView) v.findViewById(R.id.ActiveOrderAmount); rate = (TextView) v.findViewById(R.id.ActiveOrderRate); timestamp = (TextView) v.findViewById(R.id.ActiveOrderTimestamp); orderID = (TextView) v.findViewById(R.id.ActiveOrderID); ImageView remove = (ImageView) v.findViewById(R.id.removeOrder); remove.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final int order_id = dataToDisplay.optInt("id"); new AlertDialog.Builder(mContext).setTitle("Remove confirmation") .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { new CancelActiveOrder().execute(order_id); } }).setNegativeButton("No", null).setMessage("Are you sure you want to delete OrderID=" + dataToDisplay.optString("id") + "?") .show(); } }); try { String pairValue = dataToDisplay.getString("pair"); Calendar calendar = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault()); pair.setText(pairValue.replace("_", "/").toUpperCase(Locale.US)); type.setText(dataToDisplay.getString("type")); amount.setText( dataToDisplay.getString("amount") + " " + pairValue.substring(0, 3).toUpperCase(Locale.US)); rate.setText(dataToDisplay.getString("rate") + " " + pairValue.substring(4).toUpperCase(Locale.US)); calendar.setTimeInMillis(Long.parseLong(dataToDisplay.getString("timestamp_created")) * 1000L); timestamp.setText(mDateFormat.format(calendar.getTime())); orderID.setText(String.valueOf(mData.get(position).optInt("id"))); } catch (JSONException e) { e.printStackTrace(); } default: break; } return v; }
From source file:com.autodomum.daylight.algorithm.DaylightAlgorithm.java
@Override public Date sunrise(final Coordinate coordinate, final Date date) { final Calendar calendar = GregorianCalendar.getInstance(); calendar.setTime(date);/*from w ww . j av a 2 s .co m*/ final int day = calendar.get(Calendar.DAY_OF_YEAR); final double total = length(coordinate.getLatitude(), day); final int hours = (int) total; final int minutes = (int) ((((double) total) - ((double) hours)) * 60d); calendar.set(Calendar.HOUR_OF_DAY, 12); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.HOUR_OF_DAY, -hours / 2); calendar.add(Calendar.MINUTE, -minutes / 2); calendar.add(Calendar.MINUTE, (int) localSolarTime(day)); final TimeZone timeZone = TimeZone.getDefault(); if (timeZone.inDaylightTime(date)) { calendar.add(Calendar.MILLISECOND, timeZone.getDSTSavings()); } return calendar.getTime(); }
From source file:com.opengamma.web.WebAbout.java
/** * Gets the default time-zone. * @return the default time-zone */ public String getDefaultTimeZone() { return TimeZone.getDefault().getID(); }
From source file:com.microsoft.tfs.core.TFSConfigurationServer.java
/** * A convenience constructor to create a {@link TFSConfigurationServer} from * a {@link URI} and {@link Credentials}. A default * {@link ConnectionAdvisor} is used.//from ww w. jav a2 s . co m * * @param serverURI * the {@link URI} to connect to (must not be <code>null</code>) * @param credentials * the {@link Credentials} to connect with */ public TFSConfigurationServer(final URI serverURI, final Credentials credentials) { this(serverURI, credentials, new DefaultConnectionAdvisor(Locale.getDefault(), TimeZone.getDefault())); /* * TODO Remove this when we have an SDK so they don't get warnings? For * now it helps with the persistence transition. */ final String messageFormat = "Using {0} for TFSConfigurationServer, which is undesirable for Team Foundation Server client applications"; //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, DefaultConnectionAdvisor.class.getName()); log.warn(message); }
From source file:org.jstockchart.axis.TimeseriesDateAxis.java
/** * Creates a new <code>TimeseriesDateAxis</code> instance. * /* w ww .java 2 s.c o m*/ * @param lable * the axis label. * @param logicTicks * the logic date ticks. */ public TimeseriesDateAxis(String lable, List<LogicDateTick> logicTicks) { this(lable, logicTicks, TimeZone.getDefault(), Locale.getDefault()); }
From source file:com.mi.xserv.XservBase.java
protected int getTimeZoneDst() { // Daylight savings Date today = new Date(); TimeZone timezone = TimeZone.getDefault(); boolean isDST = timezone.inDaylightTime(today); return isDST ? 1 : 0; }
From source file:com.haulmont.cuba.core.sys.querymacro.TimeBetweenQueryMacroHandler.java
@Override protected String doExpand(String macro) { count++;/*from w w w . ja va2 s.c om*/ String[] args = macro.split(","); if (args.length != 4 && args.length != 5) throw new RuntimeException("Invalid macro: " + macro); String field = args[0]; TimeZone timeZone = getTimeZoneFromArgs(args, 4); if (timeZone == null) { timeZone = TimeZone.getDefault(); } String param1 = getParam(args, 1, timeZone); String param2 = getParam(args, 2, timeZone); return String.format("(%s >= :%s and %s < :%s)", field, param1, field, param2); }