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:com.arm.connector.bridge.core.Utils.java

public static int getUTCOffset() {
    TimeZone tz = TimeZone.getDefault();
    Calendar cal = GregorianCalendar.getInstance(tz);
    return tz.getOffset(cal.getTimeInMillis());
}

From source file:Main.java

private static int getDiffTimeZoneRawOffset(String timeZoneId) {
    return TimeZone.getDefault().getRawOffset() - TimeZone.getTimeZone(timeZoneId).getRawOffset();
}

From source file:DateUtility.java

/**
 * Returns a primitive long which represents the timestamp of the last millisecond
 * of the month matching the supplied parameters.  This method assumes the
 * default timezone.//from   w w w .ja  v  a2  s  . c o m
 * @param year
 * @param month
 * @return long
 */
static public long getLastMilliOfMonth(String year, String month) {
    return getLastMilliOfMonth(year, month, TimeZone.getDefault());
}

From source file:org.sharetask.data.IntegrationTest.java

@BeforeClass
public static void showInfo() {
    // show timezone
    System.out.println("******************************************************************************");
    System.out.println("Default time zone name: " + TimeZone.getDefault().getDisplayName());
    System.out.println("Default time zone id: " + TimeZone.getDefault().getID());
    System.out.println("******************************************************************************");
}

From source file:io.github.sparta.helpers.date.DateUtil.java

/**
 * convert server date to new date with user Locale.
 * /*w  ww .j  a va  2  s  .c  o  m*/
 * @param userTimeZone
 *            user TimeZone id
 * @param serverDate
 *            date in server's Local
 * @return serverDate data in user's Local
 */
public static Date convertToUserDate(String userTimeZone, Date serverDate) {
    TimeZone userLocal = TimeZone.getTimeZone(userTimeZone);
    int rawOffset = userLocal.getRawOffset() - TimeZone.getDefault().getRawOffset();
    return new Date(serverDate.getTime() + rawOffset);
}

From source file:com.github.nmorel.gwtjackson.jackson.options.DateOptionsJacksonTest.java

@Test
public void testDeserializeDatesNotAsTimestampsAndNotUseBrowserTimezone() {
    objectMapper.setTimeZone(TimeZone.getDefault());
    DateOptionsTester.INSTANCE/*from  w  w w .  ja v a2s  .  c om*/
            .testDeserializeDatesNotAsTimestampsAndUseBrowserTimezone(createReader(BeanWithDates.class));
}

From source file:com.scvngr.levelup.core.model.util.JsonUtils.java

/**
 * Loads a {@link Date}.//from  w w w  . j a v a  2s .  co m
 *
 * @param json the object to read from.
 * @param key the key in {@code json}.
 * @return A parsed {@link Date} or {@code null} if either the key is not present or is set to
 *         {@code null}.
 * @throws JSONException if the date could not be parsed.
 */
@Nullable
/* package */static Date optDate(@NonNull final JSONObject json, @NonNull final String key)
        throws JSONException {
    Date value = null;

    if (!json.isNull(key)) {
        try {
            value = IsoDateUtils.parseIsoDatetime(json.getString(key), TimeZone.getDefault());
        } catch (final ParseException e) {
            final JSONException jsonException = new JSONException("could not parse datetime");
            jsonException.initCause(e);
            throw jsonException;
        }
    }

    return value;
}

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 {/*  w  w  w.  j a  va 2  s. 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:ch.cyberduck.core.ftp.FTPParserFactory.java

public CompositeFileEntryParser createFileEntryParser(final String system)
        throws ParserInitializationException {
    return this.createFileEntryParser(system, TimeZone.getDefault());
}

From source file:com.haulmont.cuba.core.sys.querymacro.DateAfterMacroHandler.java

@Override
public Map<String, Object> getParams() {
    Map<String, Object> params = new HashMap<>();
    for (Pair<String, TimeZone> pair : paramNames) {
        String paramName = pair.getFirst();
        TimeZone timeZone = pair.getSecond() == null ? TimeZone.getDefault() : pair.getSecond();
        Date date = (Date) namedParameters.get(paramName);
        if (date == null)
            throw new RuntimeException("Parameter " + paramName + " not found for macro");

        Calendar calendar = Calendar.getInstance(timeZone);
        calendar.setTime(date);// www .java  2 s. c om
        calendar = DateUtils.truncate(calendar, Calendar.DAY_OF_MONTH);
        params.put(paramName, calendar.getTime());
    }
    return params;
}