List of usage examples for java.text SimpleDateFormat setTimeZone
public void setTimeZone(TimeZone zone)
From source file:com.wet.wired.jsr.recorder.JRecorder.java
public void frameRecorded(boolean fullFrame, long frameTime) { frameCount++;/*from w w w . j av a2 s .co m*/ if (text != null) { SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss.S"); df.setTimeZone(TimeZone.getTimeZone("GMT")); String time = df.format(frameTime); String totalTime = df.format(MAX_RECORDTIME_IN_MILLIS); if ((MAX_RECORDTIME_IN_MILLIS - frameTime) <= 30000) { text.setForeground(Color.RED); } else { text.setForeground(Color.BLACK); } text.setText("Frame: " + frameCount + " Time: " + time + "/" + totalTime); checkAutoStop(frameTime); } }
From source file:org.onebusaway.webapp.actions.where.ScheduleAction.java
private <T> List<T> getTimesByFormatKeyAndValue(List<T> times, String format, String value, IAdapter<T, Date> adapter) { SimpleDateFormat df = new SimpleDateFormat(format, getLocale()); df.setTimeZone(_timeZone); List<T> results = new ArrayList<T>(); for (T time : times) { Date date = adapter.adapt(time); String v = df.format(date); if (v.equals(value)) results.add(time);//from w w w . j a v a2 s .co m } return results; }
From source file:hudson.plugins.clearcase.action.UcmDynamicCheckoutAction.java
public boolean checkoutCodeFreeze(String viewName) throws IOException, InterruptedException { // validate no other build is running on the same stream synchronized (build.getProject()) { ClearCaseDataAction clearcaseDataAction = null; Run previousBuild = build.getPreviousBuild(); while (previousBuild != null) { clearcaseDataAction = previousBuild.getAction(ClearCaseDataAction.class); if (previousBuild.isBuilding() && clearcaseDataAction != null && clearcaseDataAction.getStream().equals(stream)) throw new IOException("Can't run build on stream " + stream + " when build " + previousBuild.getNumber() + " is currently running on the same stream."); previousBuild = previousBuild.getPreviousBuild(); }// www .ja v a2 s. c om } // prepare stream and views prepareBuildStreamAndViews(viewName, stream); // make baselines SimpleDateFormat formatter = new SimpleDateFormat("d-MMM-yy_HH_mm_ss", Locale.US); formatter.setTimeZone(TimeZone.getTimeZone("UTC")); String dateStr = formatter.format(build.getTimestamp().getTime()).toLowerCase(); UcmCommon.makeBaseline(cleartool.getLauncher(), true, getConfiguredStreamViewName(), null, BASELINE_NAME + dateStr, BASELINE_COMMENT + dateStr, false, false, null); // get latest baselines on the configured stream List<UcmCommon.BaselineDesc> latestBlsOnConfgiuredStream = UcmCommon .getLatestBlsWithCompOnStream(cleartool.getLauncher(), stream, getConfiguredStreamViewName()); // fix Not labeled baselines for (BaselineDesc baseLineDesc : latestBlsOnConfgiuredStream) { if (baseLineDesc.isNotLabeled() && baseLineDesc.getComponentDesc().isModifiable()) { // if the base is not labeled create identical one List<String> readWriteCompList = new ArrayList<String>(); readWriteCompList.add(baseLineDesc.getComponentDesc().getName()); List<BaselineDesc> baseLineDescList = UcmCommon.makeBaseline(cleartool.getLauncher(), true, getConfiguredStreamViewName(), null, BASELINE_NAME + dateStr, BASELINE_COMMENT + dateStr, true, false, readWriteCompList); String newBaseline = baseLineDescList.get(0).getBaselineName() + "@" + UcmCommon.getVob(baseLineDesc.getComponentDesc().getName()); baseLineDesc.setBaselineName(newBaseline); } } // rebase build stream UcmCommon.rebase(cleartool.getLauncher(), viewName, latestBlsOnConfgiuredStream); // add baselines to build - to be later used by getChange ClearCaseDataAction dataAction = build.getAction(ClearCaseDataAction.class); if (dataAction != null) dataAction.setLatestBlsOnConfiguredStream(latestBlsOnConfgiuredStream); return true; }
From source file:com.clustercontrol.jobmanagement.composite.JobPlanComposite.java
/** * ???<BR>//w ww. j av a 2 s. c o m * ??????[]??????? * <p> * <ol> * <li>???[]?????</li> * <li>??????[]?????</li> * <li>?[]???</li> * </ol> * * @param condition ? * */ public void update(String conditionManager, JobPlanFilter filter) { if (m_log.isDebugEnabled()) { String str = "managerName=" + conditionManager; if (filter == null) { str += ", filter is null"; } else { str += ", filter=[" + filter.getJobKickId() + "," + filter.getFromDate() + "," + filter.getToDate() + "]"; } m_log.debug(str); } Map<String, List<JobPlan>> dispDataMap = new ConcurrentHashMap<String, List<JobPlan>>(); //[]? int plans = ClusterControlPlugin.getDefault().getPreferenceStore() .getInt(JobManagementPreferencePage.P_PLAN_MAX_SCHEDULE); Map<String, String> errorMsgs = new ConcurrentHashMap<>(); if (conditionManager == null || conditionManager.equals("")) { for (String managerName : EndpointManager.getActiveManagerSet()) { getPlanList(managerName, filter, plans, dispDataMap, errorMsgs); } } else { getPlanList(conditionManager, filter, plans, dispDataMap, errorMsgs); } // if (0 < errorMsgs.size()) { UIManager.showMessageBox(errorMsgs, true); } List<JobPlan> planList = jobPlanDataMap2SortedList(dispDataMap); ArrayList<Object> listInput = new ArrayList<Object>(); SimpleDateFormat sdfYmd = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); sdfYmd.setTimeZone(TimezoneUtil.getTimeZone()); for (JobPlan plan : planList) { ArrayList<Object> a = new ArrayList<Object>(); a.add(plan.getManagerName()); String date = sdfYmd.format(plan.getDate()); a.add(date); a.add(plan.getJobKickId()); a.add(plan.getJobKickName()); a.add(plan.getJobunitId()); a.add(plan.getJobId()); a.add(plan.getJobName()); listInput.add(a); } m_viewer.setInput(listInput); //selectPlan(listInput); if (filter != null) { m_labelType.setText(Messages.getString("filtered.list")); Object[] args = { listInput.size() }; m_labelCount.setText(Messages.getString("filtered.records", args)); } else { // (??????????) m_labelType.setText(""); Object[] args = null; if (plans > listInput.size()) { args = new Object[] { listInput.size() }; } else { args = new Object[] { plans }; } m_labelCount.setText(Messages.getString("records", args)); } }
From source file:ddf.catalog.transformer.input.geojson.GeoJsonInputTransformer.java
private Serializable convertValue(Object value, AttributeFormat format) throws ParseException { if (value == null) { return null; }// w ww .j a v a 2 s . c o m switch (format) { case BINARY: return DatatypeConverter.parseBase64Binary(value.toString()); case DATE: SimpleDateFormat dateFormat = new SimpleDateFormat(ISO_8601_DATE_FORMAT); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); return dateFormat.parse(value.toString()); case GEOMETRY: case STRING: case XML: return value.toString(); case BOOLEAN: return Boolean.parseBoolean(value.toString()); case SHORT: return Short.parseShort(value.toString()); case INTEGER: return Integer.parseInt(value.toString()); case LONG: return Long.parseLong(value.toString()); case FLOAT: return Float.parseFloat(value.toString()); case DOUBLE: return Double.parseDouble(value.toString()); default: return null; } }
From source file:com.robin.utilities.Utilities.java
/** * Formats a date to string by SimpledateFormat rules in a given time zone * and the locale to use.//from w w w . j a v a 2 s .c o m * @param date the date to write to string * @param dateFormat the format string of the returned time text. (e.g. * "yyyy-MM-dd HH:mm:ss") * @param timeZone the time zone of the current time * @param locale The locale to use. * @return The date formatted according to the given dateFormat and time * zone. */ public String dateToString(final Date date, final String dateFormat, final TimeZone timeZone, final Locale locale) { SimpleDateFormat sdf = new SimpleDateFormat(dateFormat, locale); sdf.setTimeZone(timeZone); return sdf.format(date); }
From source file:hudson.plugins.simpleupdatesite.HPI.java
public JSONObject toJSON() { JSONObject jsonObject = new JSONObject(); jsonObject.put("name", this.name); jsonObject.put("version", this.version); jsonObject.put("wiki", this.wiki); jsonObject.put("title", this.title); jsonObject.put("version", this.version); jsonObject.put("pluginVersion", this.pluginVersion); jsonObject.put("buildDate", getTimestampAsString()); jsonObject.put("requiredCore", this.requiredCore); jsonObject.put("compatibleSinceVersion", this.compatibleSinceVersion); SimpleDateFormat fisheyeDateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.00Z'", Locale.US); fisheyeDateFormatter.setTimeZone(TimeZone.getTimeZone("UTC")); jsonObject.put("releaseTimestamp", fisheyeDateFormatter.format(this.timestamp)); JSONArray deps = new JSONArray(); for (HPI.Dependency dependency : getDependencies()) { deps.add(dependency.toJSON());/* w w w .j av a2s. c o m*/ } jsonObject.put("dependencies", deps); JSONArray devs = new JSONArray(); List<HPI.Developer> devList = getDevelopers(); if (!devList.isEmpty()) { for (HPI.Developer dev : devList) { devs.add(dev.toJSON()); } } else { devs.add(new HPI.Developer("", this.builtBy, "").toJSON()); } jsonObject.put("developers", devs); return jsonObject; }
From source file:com.pursuer.reader.easyrss.WebpageItemViewCtrl.java
@SuppressLint("SimpleDateFormat") private void showMobilizedPage() { showMobilized = true;/* w w w . j a va2s.com*/ view.findViewById(R.id.Mobilized).setVisibility(View.VISIBLE); view.findViewById(R.id.OriginalContent).setVisibility(View.GONE); view.findViewById(R.id.BtnMobilzedPage).setEnabled(false); view.findViewById(R.id.BtnOriginalPage).setEnabled(true); view.findViewById(R.id.OriginalProgress).setVisibility(View.GONE); view.findViewById(R.id.MobilizedProgress).setVisibility(View.VISIBLE); view.findViewById(R.id.MobilizedContent).setVisibility(View.GONE); final TextView title = (TextView) view.findViewById(R.id.ItemTitle); title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSize * 4 / 3); title.setText(item.getTitle()); final TextView info = (TextView) view.findViewById(R.id.ItemInfo); info.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSize * 4 / 5); final StringBuilder infoText = new StringBuilder(); final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); sdf.setTimeZone(TimeZone.getDefault()); infoText.append(sdf.format(Utils.timestampToDate(item.getTimestamp()))); if (item.getAuthor() != null && item.getAuthor().length() > 0) { infoText.append(" | By "); infoText.append(item.getAuthor()); } if (item.getSourceTitle() != null && item.getSourceTitle().length() > 0) { infoText.append(" ("); infoText.append(item.getSourceTitle()); infoText.append(")"); } info.setText(infoText); if (thread == null) { thread = new Thread(new Runnable() { @SuppressWarnings("deprecation") @Override public void run() { try { final StringBuilder urlBuilder = new StringBuilder(); urlBuilder.append("http://easyrss.pursuer.me/parser?url="); urlBuilder.append(URLEncoder.encode(item.getHref())); urlBuilder.append("&email="); urlBuilder.append(URLEncoder.encode(dataMgr.getSettingByName(Setting.SETTING_USERNAME))); urlBuilder.append("&version="); urlBuilder.append(context.getString(R.string.Version)); final URLConnection connection = new URL(urlBuilder.toString()).openConnection(); connection.setConnectTimeout(30 * 1000); connection.setReadTimeout(20 * 1000); final InputStreamReader input = new InputStreamReader(connection.getInputStream()); final StringBuilder builder = new StringBuilder(); final char buff[] = new char[8192]; int len; while ((len = input.read(buff)) != -1) { builder.append(new String(buff, 0, len)); } builder.append(theme == SettingTheme.THEME_NORMAL ? DataUtils.DEFAULT_NORMAL_CSS : DataUtils.DEFAULT_DARK_CSS); pageContent = builder.toString(); handler.sendMessage(handler.obtainMessage(MSG_LOADING_FINISHED, WebpageItemViewCtrl.this)); } catch (final MalformedURLException exception) { exception.printStackTrace(); pageContent = genFailedToLoadContentPage(context, theme); handler.sendMessage(handler.obtainMessage(MSG_LOADING_FINISHED, WebpageItemViewCtrl.this)); } catch (final IOException exception) { exception.printStackTrace(); pageContent = genFailedToLoadContentPage(context, theme); handler.sendMessage(handler.obtainMessage(MSG_LOADING_FINISHED, WebpageItemViewCtrl.this)); } } }); thread.setPriority(Thread.MIN_PRIORITY); thread.start(); } else if (!thread.isAlive()) { handler.sendMessage(handler.obtainMessage(MSG_LOADING_FINISHED, WebpageItemViewCtrl.this)); } }
From source file:com.bstek.dorado.web.resolver.AbstractWebFileResolver.java
protected void outputResourcesWrapper(ResourcesWrapper resourcesWrapper, HttpServletRequest request, HttpServletResponse response) throws Exception { if (resourcesWrapper.getHttpStatus() != 0) { response.setStatus(resourcesWrapper.getHttpStatus()); } else {// ww w .j a va 2 s .c o m // ?Client??-1 long cachedLastModified = request.getDateHeader(HttpConstants.IF_MODIFIED_SINCE); // ?Server?? long lastModified = resourcesWrapper.getLastModified(); // ?Client if (lastModified != 0 && cachedLastModified != 0 && Math.abs(lastModified - cachedLastModified) < ONE_SECOND) { // ?Server???Client response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); } else { String contentType = getContentType(resourcesWrapper); response.setContentType(contentType); // Client?? SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH); dateFormat.setTimeZone(GMT_TIME_ZONE); response.addHeader(HttpConstants.LAST_MODIFIED, dateFormat.format(new Date(lastModified))); Resource[] resources = resourcesWrapper.getResources(); OutputStream out = getOutputStream(request, response, resourcesWrapper); try { for (int i = 0; i < resources.length; i++) { if (i > 0 && contentType.contains("text")) { out.write("\n".getBytes(response.getCharacterEncoding())); } outputFile(out, resources[i]); } } finally { try { out.close(); } catch (IOException e) { // do nothing } } } } }
From source file:au.org.ands.vocabs.toolkit.tasks.TaskRunner.java
/** * Add a timestamp to the results map.// www .j a v a2 s. c o m * @param resultsMap The results map to which the timestamp is to be added. */ public final void addTimestamp(final HashMap<String, String> resultsMap) { final SimpleDateFormat dateFormat = new SimpleDateFormat(TIMESTAMP_FORMAT); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); // In case you need to undo the conversion in some other part // of the code, here's how to do it: // final SimpleDateFormat dateFormat = // new SimpleDateFormat(TIMESTAMP_FORMAT); // dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); // // Get timestamp some other way than this, of course. // String timestamp = dateFormat.format(new Date()); // try { // Date date = dateFormat.parse(timestamp); // logger.debug("Timestamp string is: " + timestamp); // logger.debug("Date is: " + date); // } catch (ParseException e) { // logger.error("Exception parsing timestamp", e); // } resultsMap.put("timestamp", dateFormat.format(new Date())); }