List of usage examples for java.util TimeZone getTimeZone
public static TimeZone getTimeZone(ZoneId zoneId)
From source file:com.unboundid.scim2.common.GenericScimResourceObjectTest.java
/** * Constructor. Sets up the dateFormat. */ public GenericScimResourceObjectTest() { dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); }
From source file:nz.net.orcon.kanban.tools.MapJsonSerializer.java
@Override public void serialize(Map<String, Object> fields, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeStartObject();/*from ww w . j av a2 s . c om*/ for (Entry<String, Object> entry : fields.entrySet()) { Object objectValue = entry.getValue(); if (objectValue instanceof Date) { Date date = (Date) objectValue; SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland")); String formattedDate = simpleDateFormat.format(date); jgen.writeObjectField(entry.getKey().toString(), formattedDate); } else { jgen.writeObjectField(entry.getKey().toString(), objectValue); } } jgen.writeEndObject(); }
From source file:com.microsoft.exchange.DateHelpTest.java
@Test public void systemTimeZone() { List<String> availableIDs = Arrays.asList(TimeZone.getAvailableIDs()); assertFalse(CollectionUtils.isEmpty(availableIDs)); assertTrue(availableIDs.contains(TimeZones.UTC_ID)); assertTrue(availableIDs.contains("UTC")); TimeZone ical4jUTC = TimeZone.getTimeZone(TimeZones.UTC_ID); TimeZone sysUTC = TimeZone.getTimeZone("UTC"); assertEquals(ical4jUTC.getDSTSavings(), sysUTC.getDSTSavings()); assertEquals(ical4jUTC.getRawOffset(), sysUTC.getRawOffset()); assertTrue(ical4jUTC.hasSameRules(sysUTC)); TimeZone origDefaultTimeZone = TimeZone.getDefault(); assertNotNull(origDefaultTimeZone);//w w w .j a va 2s .c om assertEquals(TimeZone.getDefault().getRawOffset(), origDefaultTimeZone.getRawOffset()); log.info("TimeZone.DisplayName=" + origDefaultTimeZone.getDisplayName()); log.info("TimeZone.ID=" + origDefaultTimeZone.getID()); log.info("TimeZone.DSTSavings=" + origDefaultTimeZone.getDSTSavings()); log.info("TimeZone.RawOffset=" + origDefaultTimeZone.getRawOffset()); log.info("TimeZone.useDaylightTime=" + origDefaultTimeZone.useDaylightTime()); TimeZone.setDefault(ical4jUTC); assertEquals(ical4jUTC, TimeZone.getDefault()); log.info(" -- Defualt Time Zone has been changed successfully! -- "); TimeZone newDefaultTimeZone = TimeZone.getDefault(); log.info("TimeZone.DisplayName=" + newDefaultTimeZone.getDisplayName()); log.info("TimeZone.ID=" + newDefaultTimeZone.getID()); log.info("TimeZone.DSTSavings=" + newDefaultTimeZone.getDSTSavings()); log.info("TimeZone.RawOffset=" + newDefaultTimeZone.getRawOffset()); log.info("TimeZone.useDaylightTime=" + newDefaultTimeZone.useDaylightTime()); }
From source file:org.elasticsearch.river.solr.support.SolrIndexer.java
public SolrIndexer(String solrUrl) { this.httpClient = HttpClients.createDefault(); this.solrUrl = solrUrl + "/update"; this.objectMapper = new ObjectMapper(); this.objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); objectMapper.setDateFormat(dateFormat); }
From source file:eu.liveGov.libraries.livegovtoolkit.helper.LogFileHelper.java
public void postLogFile(Context con) { if (logFileLocation != null) { logger.info("postLogFile; prepaire to send log file"); File file = new File(logFileLocation); File tmpFile = new File(logFileLocation + ".tmp"); if (tmpFile.exists()) tmpFile.delete();//w w w.j a v a2s . c om try { copy(file, tmpFile); new FileOutputStream(file, false).close(); //creates an empty log file. TimeZone tz = TimeZone.getTimeZone("UTC"); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); df.setTimeZone(tz); String nowAsISO = df.format(new Date()); logger.info("Starting new log file... ({})", nowAsISO); String json = "{\"filename\" : \"A_" + UserInformationHelper.getAnonymousUserId(con) + "_log.log\", \"enddate\" : \"" + nowAsISO + "\"}"; new DownloadHelper(this).postLogFile(tmpFile, json); } catch (IOException ioe) { logger.error("postLogFile; {}", ioe); try { tmpFile.delete(); } catch (Exception e) { } } } }
From source file:at.general.solutions.android.ical.parser.ICalParserThread.java
public ICalParserThread(String icalDefaultTimeZone, String userTimeZone, String toParse) { if (icalDefaultTimeZone.equalsIgnoreCase(PreferencesUtility.DEFAULT_TIMEZONE_PREF_VALUE)) { this.icalDefaultTimeZone = TimeZone.getTimeZone("UTC"); } else {//from w w w . j a va 2s.c om this.icalDefaultTimeZone = TimeZone.getTimeZone(icalDefaultTimeZone); } if (userTimeZone.equals(PreferencesUtility.DEFAULT_TIMEZONE_PREF_VALUE)) { this.userTimeZone = TimeZone.getDefault(); } else { this.userTimeZone = TimeZone.getTimeZone(userTimeZone); } ICAL_DATETIME_FORMAT.setTimeZone(this.icalDefaultTimeZone); ICAL_DATE_FORMAT.setTimeZone(this.icalDefaultTimeZone); this.toParse = toParse; }
From source file:fi.helsinki.opintoni.service.TimeService.java
public String toHelsinkiTimeFromUTC(DateTime dateTime) { return dateTime.toDateTime(DateTimeZone.forTimeZone(TimeZone.getTimeZone(HELSINKI_ZONE_ID))) .toString("dd.MM.yyyy HH:mm"); }
From source file:com.netflix.simianarmy.basic.BasicCalendar.java
/** * Instantiates a new basic calendar.// w ww. j a va 2 s. c om * * @param cfg * the monkey configuration */ public BasicCalendar(MonkeyConfiguration cfg) { this.cfg = cfg; openHour = (int) cfg.getNumOrElse("simianarmy.calendar.openHour", 9); closeHour = (int) cfg.getNumOrElse("simianarmy.calendar.closeHour", 15); tz = TimeZone.getTimeZone(cfg.getStrOrElse("simianarmy.calendar.timezone", "America/Los_Angeles")); }
From source file:ch.cyberduck.core.ftp.FTPParserFactory.java
public CompositeFileEntryParser createFileEntryParser(final FTPClientConfig config) throws ParserInitializationException { return this.createFileEntryParser(config.getServerSystemKey(), TimeZone.getTimeZone(config.getServerTimeZoneId())); }
From source file:DateUtils.java
public static final String dateToString(Date dt, String tzString, String dateformat) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(dt);//from w ww. j a v a 2 s . c o m cal.setTimeZone(TimeZone.getTimeZone(tzString)); StringBuffer ret = new StringBuffer(); String separator = new String(); if (dateformat.equals(DateUtils.FORMAT_YYYYMMDD)) { separator = "-"; } if (dateformat.equals(DateUtils.FORMAT_YYYYMMDD_SLASHES)) { separator = "/"; } ret.append(cal.get(Calendar.YEAR)); ret.append(separator); ret.append(cal.get(Calendar.MONTH) + 1); ret.append(separator); ret.append(cal.get(Calendar.DATE)); return ret.toString(); }