Example usage for java.util TimeZone getDefault

List of usage examples for java.util TimeZone getDefault

Introduction

In this page you can find the example usage for java.util TimeZone getDefault.

Prototype

public static TimeZone getDefault() 

Source Link

Document

Gets the default TimeZone of the Java virtual machine.

Usage

From source file:net.audumla.astronomy.algorithims.AstronomicalTest.java

@Before
public void setUp() throws Exception {
    deftz = TimeZone.getDefault();
}

From source file:net.centro.rtb.monitoringcenter.infos.JvmInfo.java

public static JvmInfo create() {
    JvmInfo jvmInfo = new JvmInfo();

    jvmInfo.specVersion = SystemUtils.JAVA_SPECIFICATION_VERSION;
    jvmInfo.classVersion = SystemUtils.JAVA_CLASS_VERSION;
    jvmInfo.jreVersion = SystemUtils.JAVA_VERSION;
    jvmInfo.jreVendor = SystemUtils.JAVA_VENDOR;
    jvmInfo.vmName = SystemUtils.JAVA_VM_NAME;
    jvmInfo.vmVendor = SystemUtils.JAVA_VM_VENDOR;
    jvmInfo.vmVersion = SystemUtils.JAVA_VM_VERSION;

    RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
    jvmInfo.inputArguments = new ArrayList<>(runtimeMXBean.getInputArguments());
    jvmInfo.startedTimestamp = new Date(runtimeMXBean.getStartTime());

    jvmInfo.defaultTimeZone = TimeZone.getDefault().getID();
    jvmInfo.defaultCharset = Charset.defaultCharset().displayName();

    return jvmInfo;
}

From source file:com.triage.sqlgoat.tests.TestBytemanScaffold.java

@Test
@BMScript(value = "scaffoldhelpertest", dir = "target/test-classes/btmrules")
public void testBytemanRuleFromFileWithHelper() {
    String name = TimeZone.getDefault().getDisplayName();
    assertEquals(TestHelper.TEST_TEXT, name);
}

From source file:jp.xet.baseunits.spring.StringTimePointGenericConverter.java

/**
 * ??//from  www .ja v a 2 s  .c om
 * 
 * @param format 
 * @throws NullPointerException ?{@code null}???
 */
public StringTimePointGenericConverter(String format) {
    this(format, TimeZone.getDefault());
}

From source file:Main.java

/**
 * This method returns the number of milliseconds (UTC time) for today's date at midnight in
 * the local time zone. For example, if you live in California and the day is September 20th,
 * 2016 and it is 6:30 PM, it will return 1474329600000. Now, if you plug this number into an
 * Epoch time converter, you may be confused that it tells you this time stamp represents 8:00
 * PM on September 19th local time, rather than September 20th. We're concerned with the GMT
 * date here though, which is correct, stating September 20th, 2016 at midnight.
 *
 * As another example, if you are in Hong Kong and the day is September 20th, 2016 and it is
 * 6:30 PM, this method will return 1474329600000. Again, if you plug this number into an Epoch
 * time converter, you won't get midnight for your local time zone. Just keep in mind that we
 * are just looking at the GMT date here.
 *
 * This method will ALWAYS return the date at midnight (in GMT time) for the time zone you
 * are currently in. In other words, the GMT date will always represent your date.
 *
 * Since UTC / GMT time are the standard for all time zones in the world, we use it to
 * normalize our dates that are stored in the database. When we extract values from the
 * database, we adjust for the current time zone using time zone offsets.
 *
 * @return The number of milliseconds (UTC / GMT) for today's date at midnight in the local
 * time zone//from www  .  j av a 2s. c o  m
 */
public static long getNormalizedUtcDateForToday() {

    /*
     * This number represents the number of milliseconds that have elapsed since January
     * 1st, 1970 at midnight in the GMT time zone.
     */
    long utcNowMillis = System.currentTimeMillis();

    /*
     * This TimeZone represents the device's current time zone. It provides us with a means
     * of acquiring the offset for local time from a UTC time stamp.
     */
    TimeZone currentTimeZone = TimeZone.getDefault();

    /*
     * The getOffset method returns the number of milliseconds to add to UTC time to get the
     * elapsed time since the epoch for our current time zone. We pass the current UTC time
     * into this method so it can determine changes to account for daylight savings time.
     */
    long gmtOffsetMillis = currentTimeZone.getOffset(utcNowMillis);

    /*
     * UTC time is measured in milliseconds from January 1, 1970 at midnight from the GMT
     * time zone. Depending on your time zone, the time since January 1, 1970 at midnight (GMT)
     * will be greater or smaller. This variable represents the number of milliseconds since
     * January 1, 1970 (GMT) time.
     */
    long timeSinceEpochLocalTimeMillis = utcNowMillis + gmtOffsetMillis;

    /* This method simply converts milliseconds to days, disregarding any fractional days */
    long daysSinceEpochLocal = TimeUnit.MILLISECONDS.toDays(timeSinceEpochLocalTimeMillis);

    /*
     * Finally, we convert back to milliseconds. This time stamp represents today's date at
     * midnight in GMT time. We will need to account for local time zone offsets when
     * extracting this information from the database.
     */
    long normalizedUtcMidnightMillis = TimeUnit.DAYS.toMillis(daysSinceEpochLocal);

    return normalizedUtcMidnightMillis;
}

From source file:org.arrow.util.TriggerUtils.java

/**
 * Indicates if the given scheduler string is in cron format.
 * /*from  w w w  . j a v  a2  s  . c  o  m*/
 * @param str the cron string
 * @return boolean
 */
public static boolean isCron(String str) {
    try {
        new CronSequenceGenerator(str, TimeZone.getDefault());
        return true;
    } catch (IllegalArgumentException ex) {
        return false;
    }
}

From source file:com.github.rnewson.couchdb.lucene.DocumentConverterTest.java

@Before
public void setup() {
    context = Context.enter();
    tz = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
}

From source file:charva.awt.util.DateEntryField.java

public DateEntryField(Dialog owner_) {
    this(owner_, TimeZone.getDefault());
}

From source file:at.alladin.rmbt.shared.Helperfunctions.java

/**
 * @return
 */
public static String getTimezoneId() {
    return TimeZone.getDefault().getID();
}

From source file:de.hybris.platform.servicelayer.cronjob.impl.DefaultJobLogConverterTest.java

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    converter = new DefaultJobLogConverter();

    formatFactory = Mockito.spy(new DefaultFormatFactory());
    ((DefaultFormatFactory) formatFactory).setI18nService(i18nService);

    Mockito.when(i18nService.getCurrentLocale()).thenReturn(Locale.getDefault());
    Mockito.when(i18nService.getCurrentTimeZone()).thenReturn(TimeZone.getDefault());

    converter.setFormatFactory(formatFactory);

}