List of usage examples for java.text SimpleDateFormat setTimeZone
public void setTimeZone(TimeZone zone)
From source file:org.runnerup.export.NikePlusSynchronizer.java
@Override public Status getFeed(FeedUpdater feedUpdater) { Status s;// w w w . ja v a 2 s . c om if ((s = connect()) != Status.OK) { return s; } try { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault()); df.setTimeZone(TimeZone.getTimeZone("UTC")); List<ContentValues> result = new ArrayList<ContentValues>(); getOwnFeed(df, result); getFriendsFeed(df, result); FeedList.sort(result); feedUpdater.addAll(result); return Status.OK; } finally { } }
From source file:com.maverick.ssl.https.HttpsURLConnection.java
void writeRequest(OutputStream out) throws IOException { DataOutputStream data = new DataOutputStream(new BufferedOutputStream(out)); if ((doOutput) && (output == null)) { throw new IOException(Messages.getString("HttpsURLConnection.noPOSTData")); //$NON-NLS-1$ }/* w w w . j av a 2s. c o m*/ if (ifModifiedSince != 0) { Date date = new Date(ifModifiedSince); SimpleDateFormat formatter = new SimpleDateFormat("EEE, d MMM yyyy hh:mm:ss z"); //$NON-NLS-1$ formatter.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$ setRequestProperty("If-Modified-Since", formatter.format(date)); //$NON-NLS-1$ } if (doOutput) { setRequestProperty("Content-length", "" + output.size()); //$NON-NLS-1$ //$NON-NLS-2$ } data.writeBytes((doOutput ? "POST" : "GET") + " " + (url.getFile().equals("") ? "/" : url.getFile()) //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$ + " HTTP/1.0\r\n"); //$NON-NLS-1$ for (int i = 0; i < requestKeys.size(); ++i) { String key = (String) requestKeys.elementAt(i); if (!key.startsWith("Proxy-")) { //$NON-NLS-1$ data.writeBytes(key + ": " + requestValues.elementAt(i) + "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$ } } data.writeBytes("\r\n"); //$NON-NLS-1$ data.flush(); if (doOutput) { output.writeTo(out); } out.flush(); }
From source file:com.wildplot.android.ankistats.HourlyBreakdown.java
public boolean calculateBreakdown(int type) { mTitle = R.string.stats_breakdown;// w ww .j a va2 s . c om mAxisTitles = new int[] { R.string.stats_time_of_day, R.string.stats_percentage_correct, R.string.stats_reviews }; mValueLabels = new int[] { R.string.stats_percentage_correct, R.string.stats_answers }; mColors = new int[] { R.color.stats_counts, R.color.stats_hours }; mType = type; String lim = _revlogLimitWholeOnly().replaceAll("[\\[\\]]", ""); if (lim.length() > 0) { lim = " and " + lim; } Calendar sd = GregorianCalendar.getInstance(); sd.setTimeInMillis(mCollectionData.getCrt() * 1000); Calendar cal = Calendar.getInstance(); TimeZone tz = TimeZone.getDefault(); /* date formatter in local timezone */ SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); sdf.setTimeZone(tz); /* print your timestamp and double check it's the date you expect */ String localTime = sdf.format(new Date(mCollectionData.getCrt() * 1000)); // I assume your timestamp is in seconds and you're converting to milliseconds? int pd = _periodDays(); if (pd > 0) { lim += " and id > " + ((mCollectionData.getDayCutoff() - (86400 * pd)) * 1000); } int hourOfDay = sd.get(GregorianCalendar.HOUR_OF_DAY); long cutoff = mCollectionData.getDayCutoff(); long cut = cutoff - sd.get(Calendar.HOUR_OF_DAY) * 3600; ArrayList<double[]> list = new ArrayList<double[]>(); Cursor cur = null; String query = "select " + "23 - ((cast((" + cut + " - id/1000) / 3600.0 as int)) % 24) as hour, " + "sum(case when ease = 1 then 0 else 1 end) / " + "cast(count() as float) * 100, " + "count() " + "from revlog where type in (0,1,2) " + lim + " " + "group by hour having count() > 30 order by hour"; Log.d(AnkiStatsApplication.TAG, sd.get(Calendar.HOUR_OF_DAY) + " : " + cutoff + " breakdown query: " + query); try { cur = mAnkiDb.getDatabase().rawQuery(query, null); while (cur.moveToNext()) { list.add(new double[] { cur.getDouble(0), cur.getDouble(1), cur.getDouble(2) }); } } finally { if (cur != null && !cur.isClosed()) { cur.close(); } } //TODO adjust for breakdown, for now only copied from intervals // small adjustment for a proper chartbuilding with achartengine // if (list.size() == 0 || list.get(0)[0] > 0) { // list.add(0, new double[] { 0, 0, 0 }); // } // if (num == -1 && list.size() < 2) { // num = 31; // } // if (type != Utils.TYPE_LIFE && list.get(list.size() - 1)[0] < num) { // list.add(new double[] { num, 0, 0 }); // } else if (type == Utils.TYPE_LIFE && list.size() < 2) { // list.add(new double[] { Math.max(12, list.get(list.size() - 1)[0] + 1), 0, 0 }); // } for (int i = 0; i < list.size(); i++) { double[] data = list.get(i); int intHour = (int) data[0]; int hour = (intHour - 4) % 24; if (hour < 0) hour += 24; data[0] = hour; list.set(i, data); } Collections.sort(list, new Comparator<double[]>() { @Override public int compare(double[] s1, double[] s2) { if (s1[0] < s2[0]) return -1; if (s1[0] > s2[0]) return 1; return 0; } }); mSeriesList = new double[4][list.size()]; mPeak = 0.0; mMcount = 0.0; double minHour = Double.MAX_VALUE; double maxHour = 0; for (int i = 0; i < list.size(); i++) { double[] data = list.get(i); int hour = (int) data[0]; //double hour = data[0]; if (hour < minHour) minHour = hour; if (hour > maxHour) maxHour = hour; double pct = data[1]; if (pct > mPeak) mPeak = pct; mSeriesList[0][i] = hour; mSeriesList[1][i] = pct; mSeriesList[2][i] = data[2]; if (i == 0) { mSeriesList[3][i] = pct; } else { double prev = mSeriesList[3][i - 1]; double diff = pct - prev; diff /= 3.0; diff = Math.round(diff * 10.0) / 10.0; mSeriesList[3][i] = prev + diff; } if (data[2] > mMcount) mMcount = data[2]; if (mSeriesList[1][i] > mMaxCards) mMaxCards = (int) mSeriesList[1][i]; } mMaxElements = (int) (maxHour - minHour); return list.size() > 0; }
From source file:com.connectsdk.service.netcast.NetcastHttpServer.java
public void start() { //TODO: this method is too complex and should be refactored if (running)//w w w .ja va 2 s .c om return; running = true; try { welcomeSocket = new ServerSocket(this.port); } catch (IOException ex) { ex.printStackTrace(); } while (running) { if (welcomeSocket == null || welcomeSocket.isClosed()) { stop(); break; } Socket connectionSocket = null; BufferedReader inFromClient = null; DataOutputStream outToClient = null; try { connectionSocket = welcomeSocket.accept(); } catch (IOException ex) { ex.printStackTrace(); // this socket may have been closed, so we'll stop stop(); return; } String str = null; int c; StringBuilder sb = new StringBuilder(); try { inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream())); while ((str = inFromClient.readLine()) != null) { if (str.equals("")) { break; } } while ((c = inFromClient.read()) != -1) { sb.append((char) c); String temp = sb.toString(); if (temp.endsWith("</envelope>")) break; } } catch (IOException ex) { ex.printStackTrace(); } String body = sb.toString(); Log.d(Util.T, "got message body: " + body); Calendar calendar = Calendar.getInstance(); SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); String date = dateFormat.format(calendar.getTime()); String androidOSVersion = android.os.Build.VERSION.RELEASE; PrintWriter out = null; try { outToClient = new DataOutputStream(connectionSocket.getOutputStream()); out = new PrintWriter(outToClient); out.println("HTTP/1.1 200 OK"); out.println("Server: Android/" + androidOSVersion + " UDAP/2.0 ConnectSDK/1.2.1"); out.println("Cache-Control: no-store, no-cache, must-revalidate"); out.println("Date: " + date); out.println("Connection: Close"); out.println("Content-Length: 0"); out.println(); out.flush(); } catch (IOException ex) { ex.printStackTrace(); } finally { try { inFromClient.close(); out.close(); outToClient.close(); connectionSocket.close(); } catch (IOException ex) { ex.printStackTrace(); } } SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); InputStream stream = null; try { stream = new ByteArrayInputStream(body.getBytes("UTF-8")); } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); } NetcastPOSTRequestParser handler = new NetcastPOSTRequestParser(); SAXParser saxParser; try { saxParser = saxParserFactory.newSAXParser(); saxParser.parse(stream, handler); } catch (IOException ex) { ex.printStackTrace(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } if (body.contains("ChannelChanged")) { ChannelInfo channel = NetcastChannelParser.parseRawChannelData(handler.getJSONObject()); Log.d(Util.T, "Channel Changed: " + channel.getNumber()); for (URLServiceSubscription<?> sub : subscriptions) { if (sub.getTarget().equalsIgnoreCase("ChannelChanged")) { for (int i = 0; i < sub.getListeners().size(); i++) { @SuppressWarnings("unchecked") ResponseListener<Object> listener = (ResponseListener<Object>) sub.getListeners() .get(i); Util.postSuccess(listener, channel); } } } } else if (body.contains("KeyboardVisible")) { boolean focused = false; TextInputStatusInfo keyboard = new TextInputStatusInfo(); keyboard.setRawData(handler.getJSONObject()); try { JSONObject currentWidget = (JSONObject) handler.getJSONObject().get("currentWidget"); focused = (Boolean) currentWidget.get("focus"); keyboard.setFocused(focused); } catch (JSONException e) { e.printStackTrace(); } Log.d(Util.T, "KeyboardFocused?: " + focused); for (URLServiceSubscription<?> sub : subscriptions) { if (sub.getTarget().equalsIgnoreCase("KeyboardVisible")) { for (int i = 0; i < sub.getListeners().size(); i++) { @SuppressWarnings("unchecked") ResponseListener<Object> listener = (ResponseListener<Object>) sub.getListeners() .get(i); Util.postSuccess(listener, keyboard); } } } } else if (body.contains("TextEdited")) { System.out.println("TextEdited"); String newValue = ""; try { newValue = handler.getJSONObject().getString("value"); } catch (JSONException ex) { ex.printStackTrace(); } Util.postSuccess(textChangedListener, newValue); } else if (body.contains("3DMode")) { try { String enabled = (String) handler.getJSONObject().get("value"); boolean bEnabled; bEnabled = enabled.equalsIgnoreCase("true"); for (URLServiceSubscription<?> sub : subscriptions) { if (sub.getTarget().equalsIgnoreCase("3DMode")) { for (int i = 0; i < sub.getListeners().size(); i++) { @SuppressWarnings("unchecked") ResponseListener<Object> listener = (ResponseListener<Object>) sub.getListeners() .get(i); Util.postSuccess(listener, bEnabled); } } } } catch (JSONException e) { e.printStackTrace(); } } } }
From source file:com.connectsdk.device.netcast.NetcastHttpServer.java
public void start() { if (running)//w w w .j ava 2s .c om return; running = true; try { welcomeSocket = new ServerSocket(this.port); } catch (IOException ex) { ex.printStackTrace(); } while (running) { if (welcomeSocket == null || welcomeSocket.isClosed()) { stop(); break; } Socket connectionSocket = null; BufferedReader inFromClient = null; DataOutputStream outToClient = null; try { connectionSocket = welcomeSocket.accept(); } catch (IOException ex) { ex.printStackTrace(); // this socket may have been closed, so we'll stop stop(); return; } String str = null; int c; StringBuilder sb = new StringBuilder(); try { inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream())); while ((str = inFromClient.readLine()) != null) { if (str.equals("")) { break; } } while ((c = inFromClient.read()) != -1) { sb.append((char) c); String temp = sb.toString(); if (temp.endsWith("</envelope>")) break; } } catch (IOException ex) { ex.printStackTrace(); } String body = sb.toString(); Log.d("Connect SDK", "got message body: " + body); Calendar calendar = Calendar.getInstance(); SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); String date = dateFormat.format(calendar.getTime()); String androidOSVersion = android.os.Build.VERSION.RELEASE; PrintWriter out = null; try { outToClient = new DataOutputStream(connectionSocket.getOutputStream()); out = new PrintWriter(outToClient); out.println("HTTP/1.1 200 OK"); out.println("Server: Android/" + androidOSVersion + " UDAP/2.0 ConnectSDK/1.2.1"); out.println("Cache-Control: no-store, no-cache, must-revalidate"); out.println("Date: " + date); out.println("Connection: Close"); out.println("Content-Length: 0"); out.flush(); } catch (IOException ex) { ex.printStackTrace(); } finally { try { inFromClient.close(); out.close(); outToClient.close(); connectionSocket.close(); } catch (IOException ex) { ex.printStackTrace(); } } SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); InputStream stream = null; try { stream = new ByteArrayInputStream(body.getBytes("UTF-8")); } catch (UnsupportedEncodingException ex) { ex.printStackTrace(); } NetcastPOSTRequestParser handler = new NetcastPOSTRequestParser(); SAXParser saxParser; try { saxParser = saxParserFactory.newSAXParser(); saxParser.parse(stream, handler); } catch (IOException ex) { ex.printStackTrace(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } if (body.contains("ChannelChanged")) { ChannelInfo channel = NetcastChannelParser.parseRawChannelData(handler.getJSONObject()); Log.d("Connect SDK", "Channel Changed: " + channel.getNumber()); for (URLServiceSubscription<?> sub : subscriptions) { if (sub.getTarget().equalsIgnoreCase("ChannelChanged")) { for (int i = 0; i < sub.getListeners().size(); i++) { @SuppressWarnings("unchecked") ResponseListener<Object> listener = (ResponseListener<Object>) sub.getListeners() .get(i); Util.postSuccess(listener, channel); } } } } else if (body.contains("KeyboardVisible")) { boolean focused = false; TextInputStatusInfo keyboard = new TextInputStatusInfo(); keyboard.setRawData(handler.getJSONObject()); try { JSONObject currentWidget = (JSONObject) handler.getJSONObject().get("currentWidget"); focused = (Boolean) currentWidget.get("focus"); keyboard.setFocused(focused); } catch (JSONException e) { e.printStackTrace(); } Log.d("Connect SDK", "KeyboardFocused?: " + focused); for (URLServiceSubscription<?> sub : subscriptions) { if (sub.getTarget().equalsIgnoreCase("KeyboardVisible")) { for (int i = 0; i < sub.getListeners().size(); i++) { @SuppressWarnings("unchecked") ResponseListener<Object> listener = (ResponseListener<Object>) sub.getListeners() .get(i); Util.postSuccess(listener, keyboard); } } } } else if (body.contains("TextEdited")) { System.out.println("TextEdited"); String newValue = ""; try { newValue = handler.getJSONObject().getString("value"); } catch (JSONException ex) { ex.printStackTrace(); } Util.postSuccess(textChangedListener, newValue); } else if (body.contains("3DMode")) { try { String enabled = (String) handler.getJSONObject().get("value"); boolean bEnabled; if (enabled.equalsIgnoreCase("true")) bEnabled = true; else bEnabled = false; for (URLServiceSubscription<?> sub : subscriptions) { if (sub.getTarget().equalsIgnoreCase("3DMode")) { for (int i = 0; i < sub.getListeners().size(); i++) { @SuppressWarnings("unchecked") ResponseListener<Object> listener = (ResponseListener<Object>) sub.getListeners() .get(i); Util.postSuccess(listener, bEnabled); } } } } catch (JSONException e) { e.printStackTrace(); } } } }
From source file:nl.minbzk.dwr.zoeken.enricher.service.EnricherService.java
/** * Reconstruct the import envelope so existing code can be used. * * @param envelope// w w w .j a v a2s.co m * @param value * @param schemaField * @throws IllegalStateException if field of enricher document can not be mapped to import envelope. */ private void mapEnricherDocumentToImportEnvelope(final ImportEnvelope envelope, final Object value, final String schemaField) { Map<String, List<String>> envelopeFields = envelope.getFields(); if (schemaField.equals("*") && value instanceof Map) { @SuppressWarnings("unchecked") Map<String, String> values = (Map<String, String>) value; Map<String, List<String>> transformedValues = Maps.transformValues(values, new Function<String, List<String>>() { @Override public List<String> apply(String s) { return Lists.newArrayList(s); } }); // create new map to avoid lazy evaluation of function envelopeFields.putAll(Maps.newHashMap(transformedValues)); } else if (value instanceof List) { @SuppressWarnings("unchecked") List<String> values = (List<String>) value; envelopeFields.put(schemaField, values); } else if (value instanceof Date) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); envelope.setSingleValue(schemaField, dateFormat.format(value)); } else if (value instanceof Integer) { envelope.setSingleValue(schemaField, value.toString()); } else if (value instanceof String) { envelope.setSingleValue(schemaField, (String) value); } else { throw new IllegalStateException("Can not apply value '" + value + "' type for schemaField " + schemaField + " to import envelope"); } }
From source file:fr.juanwolf.mysqlbinlogreplicator.component.DomainClassAnalyzerTest.java
@Test public void instantiateField_should_set_the_string_with_the_default_locale_of_the_server_if_no_dateouput_() throws ReflectiveOperationException, ParseException { // Given// www . j a va 2 s . c o m // We need to reload the domainClassAnalyzer String date = "Wed Jul 22 13:00:00 CEST 2015"; Date dateExpected = BINLOG_DATETIME_FORMATTER.parse(date); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.UK); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("Europe/Paris")); domainClassAnalyzer.postConstruct(); User user = (User) domainClassAnalyzer.generateInstanceFromName("user"); // When domainClassAnalyzer.instantiateField(user, user.getClass().getDeclaredField("dateString"), date, ColumnType.DATETIME.getCode(), "user"); // Then assertThat(BINLOG_DATETIME_FORMATTER.parse(user.getDateString())).isEqualTo(dateExpected); //assertThat(user.getDateString()).isEqualTo(date); }
From source file:contestWebsite.AdminPanel.java
@Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { VelocityEngine ve = new VelocityEngine(); ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, "html/pages, html/snippets"); ve.init();// www .ja v a 2s. c o m VelocityContext context = new VelocityContext(); Pair<Entity, UserCookie> infoAndCookie = init(context, req); UserCookie userCookie = infoAndCookie.y; boolean loggedIn = (boolean) context.get("loggedIn"); String updated = req.getParameter("updated"); if (updated != null && updated.equals("1") && !loggedIn) { resp.sendRedirect("/adminPanel?updated=1"); } context.put("updated", req.getParameter("updated")); if (loggedIn && userCookie.isAdmin()) { Entity contestInfo = infoAndCookie.x; context.put("contestInfo", contestInfo); String confPassError = req.getParameter("confPassError"); context.put("confPassError", confPassError != null && confPassError.equals("1") ? "Those passwords didn't match, try again." : null); String passError = req.getParameter("passError"); context.put("passError", passError != null && passError.equals("1") ? "That password is incorrect, try again." : null); context.put("middleSubjects", Test.getTests(Level.MIDDLE)); context.put("Level", Level.class); context.put("subjects", Subject.values()); String[] defaultEmails = { "forgotPass", "question", "registration" }; for (String defaultEmail : defaultEmails) { String email; if (contestInfo.hasProperty(defaultEmail + "Email")) { email = ((Text) contestInfo.getProperty(defaultEmail + "Email")).getValue(); } else { InputStream emailStream = getServletContext() .getResourceAsStream("/html/email/" + defaultEmail + ".html"); email = CharStreams.toString(new InputStreamReader(emailStream, Charsets.UTF_8)); emailStream.close(); } context.put(defaultEmail + "Email", email); } try { context.put("awardCriteria", Retrieve.awardCriteria(contestInfo)); context.put("qualifyingCriteria", Retrieve.qualifyingCriteria(contestInfo)); context.put("clientId", contestInfo.getProperty("OAuth2ClientId")); } catch (Exception e) { System.err.println("Surpressing exception while loading admin panel"); e.printStackTrace(); } SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT+6")); try { Date endDate = dateFormat.parse((String) contestInfo.getProperty("editEndDate")); Date startDate = dateFormat.parse((String) contestInfo.getProperty("editStartDate")); if (new Date().after(endDate) || new Date().before(startDate)) { context.put("regEditClosed", true); } } catch (Exception e) { context.put("regEditClosed", true); } try { Date endDate = dateFormat.parse((String) contestInfo.getProperty("endDate")); Date startDate = dateFormat.parse((String) contestInfo.getProperty("startDate")); if (new Date().after(endDate) || new Date().before(startDate)) { context.put("regClosed", true); } } catch (Exception e) { context.put("regClosed", true); } MemcacheService memCache = MemcacheServiceFactory.getMemcacheService(); memCache.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(java.util.logging.Level.INFO)); byte[] tabulationTaskStatusBytes = (byte[]) memCache.get("tabulationTaskStatus"); if (tabulationTaskStatusBytes != null) { String[] tabulationTaskStatus = new String(tabulationTaskStatusBytes).split("_"); context.put("tabulationTaskStatus", tabulationTaskStatus[0]); List<String> tabulationTaskStatusTime = new ArrayList<String>(); long timeAgo = new Date().getTime() - new Date(Long.parseLong(tabulationTaskStatus[1])).getTime(); List<Pair<TimeUnit, String>> timeUnits = new ArrayList<Pair<TimeUnit, String>>() { { add(new Pair<TimeUnit, String>(TimeUnit.DAYS, "day")); add(new Pair<TimeUnit, String>(TimeUnit.HOURS, "hour")); add(new Pair<TimeUnit, String>(TimeUnit.MINUTES, "minute")); add(new Pair<TimeUnit, String>(TimeUnit.SECONDS, "second")); } }; for (Pair<TimeUnit, String> entry : timeUnits) { if (entry.getX().convert(timeAgo, TimeUnit.MILLISECONDS) > 0) { long numUnit = entry.getX().convert(timeAgo, TimeUnit.MILLISECONDS); tabulationTaskStatusTime.add(numUnit + " " + entry.getY() + (numUnit == 1 ? "" : "s")); timeAgo -= TimeUnit.MILLISECONDS.convert(numUnit, entry.getX()); } } if (tabulationTaskStatusTime.size() >= 1) { context.put("tabulationTaskStatusTime", StringUtils.join(tabulationTaskStatusTime, ", ")); } else { context.put("tabulationTaskStatusTime", timeAgo + " milliseconds"); } } close(context, ve.getTemplate("adminPanel.html"), resp); } else { resp.sendError(HttpServletResponse.SC_FORBIDDEN, "Contest Administrator privileges required for that operation"); } }
From source file:com.barchart.netty.rest.client.RestClientBase.java
/** * Get a date header string that is in sync with the server. *///www.j av a 2 s . c om private String httpDate(final Date date) { // TODO account for client/service clock skew final SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); return dateFormat.format(date); }
From source file:com.redhat.rhn.frontend.action.errata.ErrataSearchAction.java
private String getDateString(Date date) { Calendar cal = Calendar.getInstance(TimeZone.getDefault()); cal.setTime(date);/*from w w w . j a v a 2s .co m*/ String dateFmt = "yyyy-MM-dd HH:mm:ss"; java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(dateFmt); sdf.setTimeZone(TimeZone.getDefault()); String currentTime = sdf.format(cal.getTime()); return currentTime; }