List of usage examples for java.util TimeZone getTimeZone
public static TimeZone getTimeZone(ZoneId zoneId)
From source file:edu.kit.dama.mdm.audit.impl.LogbackPublisher.java
@Override public void publish(AuditEvent entry) { StringBuilder b = new StringBuilder(); final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); df.setTimeZone(TimeZone.getTimeZone("UTC")); b.append(entry.getPid()).append("|").append(entry.getEventType()).append("|").append(entry.getCategory()) .append("|").append(df.format(entry.getEventDate())).append("|").append(entry.getOwner()) .append("|").append(entry.getAgent()).append("|").append(entry.getResource()).append("|") .append(entry.getDetails()); LOGGER.info(b.toString());// w w w. j a va2 s . c om }
From source file:com.easou.common.util.CommonUtils.java
public static String formatForUtcTime(final Date date) { final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); return dateFormat.format(date); }
From source file:org.shredzone.cilla.admin.TimeZoneBean.java
@PostConstruct public void setup() { for (String id : TimeZone.getAvailableIDs()) { TimeZone tz = TimeZone.getTimeZone(id); timeZoneMap.put(id, tz);//from ww w .ja v a 2 s.co m timeZoneMap.put(tz.getDisplayName(Locale.ENGLISH).toLowerCase(), tz); } }
From source file:com.alliander.osgp.webdevicesimulator.application.config.WebDeviceSimulatorInitializer.java
@Override public void onStartup(final ServletContext servletContext) throws ServletException { try {// w w w . j av a 2 s .c o m // Force the timezone of application to UTC (required for // Hibernate/JDBC) TimeZone.setDefault(TimeZone.getTimeZone("UTC")); final Context initialContext = new InitialContext(); final String logLocation = (String) initialContext .lookup("java:comp/env/osp/webDeviceSimulator/log-config"); LogbackConfigurer.initLogging(logLocation); InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory()); final AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(ApplicationContext.class); final ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(rootContext)); dispatcher.setLoadOnStartup(1); dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING); servletContext.addListener(new ContextLoaderListener(rootContext)); } catch (final NamingException e) { throw new ServletException("naming exception", e); } catch (final FileNotFoundException e) { throw new ServletException("Logging file not found", e); } catch (final JoranException e) { throw new ServletException("Logback exception", e); } }
From source file:Main.java
/** * Return now at UTC/*from www . j a v a 2 s. co m*/ * @return */ public static Calendar CalendargetInstance() { return Calendar.getInstance(TimeZone.getTimeZone("UTC")); }
From source file:com.graphaware.importer.data.access.BaseDataReader.java
/** * Create a date format for date conversions. * * @return date format. By default, it is "dd/MM/yyyy" in GMT+1. Override for different format. *///from w w w.ja v a 2 s . co m protected SimpleDateFormat dateFormat() { SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy"); format.setTimeZone(TimeZone.getTimeZone("GMT+1")); return format; }
From source file:com.appsimobile.appsii.module.weather.loader.WeatherDataParser.java
public static void parseWeatherData(CircularArray<WeatherData> result, String jsonString, CircularArray<String> woeids) throws JSONException, ResponseParserException, ParseException { if (woeids.isEmpty()) return;/*from w w w .j a v a 2s .c om*/ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yyyy", Locale.US); simpleDateFormat.setTimeZone(TimeZone.getTimeZone(Time.TIMEZONE_UTC)); SimpleJson json = new SimpleJson(jsonString); // when only a single woeid was requested, this is an object, otherwise it is an array. // So we need to check if we got an array; if so, handle each of the objects. // Otherwise get it as an object JSONArray resultsArray = json.getJsonArray("query.results.channel"); if (resultsArray == null) { JSONObject weatherObject = json.optJsonObject("query.results.channel"); if (weatherObject == null) return; String woeid = woeids.get(0); WeatherData weatherData = parseWeatherData(woeid, simpleDateFormat, weatherObject); if (weatherData != null) { result.addLast(weatherData); } return; } int length = resultsArray.length(); for (int i = 0; i < length; i++) { JSONObject weatherJson = resultsArray.getJSONObject(i); WeatherData weatherData = parseWeatherData(woeids.get(i), simpleDateFormat, weatherJson); if (weatherData == null) continue; result.addLast(weatherData); } }
From source file:mailjimp.dom.request.campaign.CampaignListRequest.java
public CampaignListRequest(String apikey, HashMap<String, Object> filters, int start, int limit) { super(apikey); this.filters = filters; this.start = start; this.limit = limit; if (df == null) { df = new DateFormatter("yyyy-MM-dd HH:mm:ss"); df.setTimeZone(TimeZone.getTimeZone("GMT")); }/*from www . j a v a2 s. c om*/ }
From source file:Main.java
public void makeUI() { String[] zones = { "Asia/Tokyo", "Asia/Hong_Kong", "Asia/Calcutta", "Europe/Paris", "Europe/London", "America/New_York", "America/Los_Angeles" }; JLabel[] labels = new JLabel[zones.length]; SimpleDateFormat[] formats = new SimpleDateFormat[zones.length]; JFrame frame = new JFrame(); Calendar cal = Calendar.getInstance(); Date date = cal.getTime();/*from ww w .j av a2s.com*/ SpinnerDateModel model = new SpinnerDateModel(); model.setValue(date); JSpinner spinner = new JSpinner(model); spinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Date date = (Date) ((JSpinner) e.getSource()).getValue(); for (int i = 0; i < labels.length; i++) { labels[i].setText(formats[i].format(date)); } } }); SimpleDateFormat format = ((JSpinner.DateEditor) spinner.getEditor()).getFormat(); format.setTimeZone(TimeZone.getTimeZone(zones[0])); format.applyPattern("yyyy-MM-dd HH:mm:ss"); JPanel panel = new JPanel(new GridLayout(zones.length, 2, 10, 10)); for (int i = 0; i < zones.length; i++) { formats[i] = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss"); formats[i].setTimeZone(TimeZone.getTimeZone(zones[i])); JLabel label = new JLabel(zones[i]); labels[i] = new JLabel(formats[i].format(date)); panel.add(label); panel.add(labels[i]); } frame.setLayout(new BorderLayout()); frame.add(spinner, BorderLayout.NORTH); frame.add(panel, BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
From source file:net.solarnetwork.util.JodaDateTimeDeserializer.java
/** * Default constructor./*from w w w . ja v a 2 s . c om*/ * * <p> * Uses the pattern <code>yyyy-MM-dd HH:mm:ss.SSS'Z'</code>. * </p> */ public JodaDateTimeDeserializer() { this("yyyy-MM-dd HH:mm:ss.SSS'Z'", TimeZone.getTimeZone("GMT")); }