List of usage examples for java.util TimeZone getDefault
public static TimeZone getDefault()
From source file:Main.java
/** * Parses a date/time string from within an XMLTV stream. Only the local * time part of the value is parsed. Timezone specifications are ignored. * // ww w . j a v a2s . c om * @param str the string * @param convertTimezone true to convert date/time values to local time * @return the date/time value as a Calendar object */ public static Calendar parseDateTime(String str, boolean convertTimezone) { // Format looks like: 20111209060000 +1100 if (str == null) return null; int year = parseField(str, 0, 4); int month = parseField(str, 4, 2); int day = parseField(str, 6, 2); int hour = parseField(str, 8, 2); int minute = parseField(str, 10, 2); int second = parseField(str, 12, 2); if (convertTimezone) { if (cachedTimeZone == null) { cachedTimeZone = TimeZone.getDefault(); cachedOffset = cachedTimeZone.getOffset(System.currentTimeMillis()); } int tz = parseTZField(str, 14); if (tz != cachedOffset) { Calendar calendar = new GregorianCalendar(year, month - 1, day, hour, minute, second); calendar.add(Calendar.MILLISECOND, cachedOffset - tz); return calendar; } } return new GregorianCalendar(year, month - 1, day, hour, minute, second); }
From source file:DateUtils.java
public static final String getCurrentDate(String format) { Calendar cal = Calendar.getInstance(TimeZone.getDefault()); java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(format); sdf.setTimeZone(TimeZone.getDefault()); return (sdf.format(cal.getTime())); }
From source file:com.triage.sqlgoat.tests.TestBytemanScaffold.java
@Test public void testNoMods() { String name = TimeZone.getDefault().getDisplayName(); }
From source file:Main.java
public static final Date stringToDate(String paramString1, String paramString2, boolean paramBoolean) { SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat(paramString2, Locale.getDefault()); localSimpleDateFormat.setTimeZone(TimeZone.getTimeZone(TimeZone.getDefault().getID())); try {/*from www . j a v a2 s . com*/ Date localDate = localSimpleDateFormat.parse(paramString1); return localDate; } catch (Throwable localThrowable) { if (!paramBoolean) { return new Date(1000L + System.currentTimeMillis()); } } return null; }
From source file:com.microsoft.tfs.client.common.ui.config.UIClientConnectionAdvisor.java
/** * Creates a {@link UIClientConnectionAdvisor} that uses the current default * {@link Locale} and {@link TimeZone} for all * {@link ConnectionInstanceData}s./* w w w. j a v a 2 s . c o m*/ */ public UIClientConnectionAdvisor() { super(Locale.getDefault(), TimeZone.getDefault()); }
From source file:ConfigTest.java
/** Create the client test. */ public ConfigTest() { this.applicationContext = new AnnotationConfigApplicationContext(ConfigA2.class); this.logger.info("Default timezone is {}", TimeZone.getDefault().getID()); }
From source file:com.triage.sqlgoat.tests.TestBytemanScaffold.java
@Test(expectedExceptions = RuntimeException.class) @BMRule(name = "throw exception Timezone", targetClass = "java.util.TimeZone", targetMethod = "getDisplayName", action = "throw new RuntimeException(\"ha ha\")") public void testInlineBytemanRule() { String name = TimeZone.getDefault().getDisplayName(); }
From source file:com.tlabs.eve.api.server.MessageOfTheDayParser.java
public MessageOfTheDayResponse parse(byte[] data) throws IOException { final int CACHE_IN_MN = /*60 * 8*/5; MessageOfTheDayResponse response = new MessageOfTheDayResponse(); long now = System.currentTimeMillis(); response.setCachedUntil(now - TimeZone.getDefault().getOffset(now) + CACHE_IN_MN * 60 * 1000); String message = new String(data); if (message.length() == 0) { //keep a content otherwise caching won't occur when the received data is empty message = "<br/>"; } else {/* ww w.j av a2 s . c o m*/ //The content is not great...we have a MOTD at start (sometimes) //or a <center>MOTD</center> or anything with such form //Also CCP found it funny to add shellexec: in front of <a> URLs. //A real XML would have been great. message = StringUtils.removeStart(message, "MOTD"); message = StringUtils.remove(message, "shellexec:"); message = StringUtils.replace(message, "<br>", "<br/>"); } response.setMessage(message); return response; }
From source file:com.tlabs.eve.api.server.ServerStatusParser.java
@Override protected void doAfterParse(ServerStatusResponse t) { long now = System.currentTimeMillis(); now = now - TimeZone.getDefault().getOffset(now); t.setCachedUntil(now + CACHE_IN_MN * 60l * 1000l); }
From source file:alfio.manager.location.MockLocationManager.java
@Override public TimeZone getTimezone(String latitude, String longitude) { return TimeZone.getDefault(); }