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:hudson.plugins.timestamper.format.TimestampFormatterImplTest.java

/**
 *//*from   w ww  . j  ava  2  s .co m*/
@Before
public void setUp() {
    systemDefaultTimeZone = TimeZone.getDefault();
    // Set the time zone to get consistent results.
    TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
    serialize = false;
}

From source file:org.jstockchart.axis.TimeseriesDateAxis.java

/**
 * Creates a new <code>TimeseriesDateAxis</code> instance.
 * // ww  w  .  j  a  v a2  s  . c o  m
 * @param logicTicks
 *            the logic date ticks.
 */
public TimeseriesDateAxis(List<LogicDateTick> logicTicks) {
    this(null, logicTicks, TimeZone.getDefault(), Locale.getDefault());
}

From source file:com.owncloud.android.services.AdvancedFileAlterationListener.java

public void onFileCreate(final File file, int delay) {
    if (file != null) {
        uploadMap.put(file.getAbsolutePath(), null);

        String mimetypeString = FileStorageUtils.getMimeTypeFromName(file.getAbsolutePath());
        Long lastModificationTime = file.lastModified();
        final Locale currentLocale = context.getResources().getConfiguration().locale;

        if ("image/jpeg".equalsIgnoreCase(mimetypeString) || "image/tiff".equalsIgnoreCase(mimetypeString)) {
            try {
                ExifInterface exifInterface = new ExifInterface(file.getAbsolutePath());
                String exifDate = exifInterface.getAttribute(ExifInterface.TAG_DATETIME);
                if (!TextUtils.isEmpty(exifDate)) {
                    ParsePosition pos = new ParsePosition(0);
                    SimpleDateFormat sFormatter = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", currentLocale);
                    sFormatter.setTimeZone(TimeZone.getTimeZone(TimeZone.getDefault().getID()));
                    Date dateTime = sFormatter.parse(exifDate, pos);
                    lastModificationTime = dateTime.getTime();
                }/*w ww .j a va 2 s  .c o  m*/

            } catch (IOException e) {
                Log_OC.d(TAG, "Failed to get the proper time " + e.getLocalizedMessage());
            }
        }

        final Long finalLastModificationTime = lastModificationTime;

        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                PersistableBundleCompat bundle = new PersistableBundleCompat();
                bundle.putString(AutoUploadJob.LOCAL_PATH, file.getAbsolutePath());
                bundle.putString(AutoUploadJob.REMOTE_PATH,
                        FileStorageUtils.getInstantUploadFilePath(currentLocale, syncedFolder.getRemotePath(),
                                file.getName(), finalLastModificationTime, syncedFolder.getSubfolderByDate()));
                bundle.putString(AutoUploadJob.ACCOUNT, syncedFolder.getAccount());
                bundle.putInt(AutoUploadJob.UPLOAD_BEHAVIOUR, syncedFolder.getUploadAction());

                new JobRequest.Builder(AutoUploadJob.TAG).setExecutionWindow(30_000L, 80_000L)
                        .setRequiresCharging(syncedFolder.getChargingOnly())
                        .setRequiredNetworkType(syncedFolder.getWifiOnly() ? JobRequest.NetworkType.UNMETERED
                                : JobRequest.NetworkType.ANY)
                        .setExtras(bundle).setPersisted(false).setRequirementsEnforced(true)
                        .setUpdateCurrent(false).build().schedule();

                uploadMap.remove(file.getAbsolutePath());
            }
        };

        uploadMap.put(file.getAbsolutePath(), runnable);
        handler.postDelayed(runnable, delay);
    }
}

From source file:com.sshdemo.common.schedule.generate.validator.JobInfoValidator.java

protected void validateJobTrigger(ValidationErrorsable errors, JobInfo job) throws BaseException {
    JobTrigger trigger = job.getTrigger();
    if (trigger == null) {
        errors.add(new ValidationError("error.alqc.job.no.trigger", null, "??.",
                "trigger"));
        return;//ww  w  . j  ava 2s  .co  m
    }

    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    Date now = calendar.getTime();
    String tzId = trigger.getTimeZone();
    if (tzId != null && tzId.length() > 0) {
        TimeZone tz = TimeZone.getTimeZone(tzId);
        now = DateBuilder.translateTime(now, tz, TimeZone.getDefault());
    }

    if (trigger.getStartType() == JobTrigger.START_TYPE_SCHEDULE) {
        Date startDate = trigger.getStartDate();
        if (startDate == null) {
            errors.add(new ValidationError("error.not.empty", null, "?.",
                    "trigger.startDate"));
            //            } else if (startDate.before(now)) {
            //                errors.add(new ValidationError("error.before.current.date", null, "?.", "trigger.startDate"));
        }
    }

    if (trigger.getEndDate() != null) {
        if (trigger.getStartType() == JobTrigger.START_TYPE_NOW) {
            if (trigger.getEndDate().before(now)) {
                errors.add(new ValidationError("error.before.current.date", null,
                        "??.", "trigger.endDate"));
            }
        } else if (trigger.getStartType() == JobTrigger.START_TYPE_SCHEDULE) {
            if (trigger.getEndDate().before(now)) {
                errors.add(new ValidationError("error.before.current.date", null,
                        "??.", "trigger.endDate"));
            }
            if (trigger.getStartDate() != null && trigger.getEndDate().before(trigger.getStartDate())) {
                errors.add(new ValidationError("error.before.start.date", null,
                        "??.", "trigger.endDate"));
            }
        }
    }

    if (trigger instanceof JobSimpleTrigger) {
        validateJobSimpleTrigger(errors, (JobSimpleTrigger) trigger);
    } else if (trigger instanceof JobCalendarTrigger) {
        validateJobCalendarTrigger(errors, (JobCalendarTrigger) trigger);
    } else {
        //            String quotedTriggerType = "\"" + trigger.getClass().getName() + "\"";
        //            throw new JSException("jsexception.job.unknown.trigger.type", new Object[] {quotedTriggerType});
        throw new BaseException("??",
                "??");
    }
}

From source file:com.auditbucket.registration.repo.neo4j.model.FortressNode.java

public String getTimeZone() {
    if (this.timeZone == null)
        this.timeZone = TimeZone.getDefault().getID();
    return timeZone;
}

From source file:com.partypoker.poker.engagement.reach.EngagementReachContent.java

/**
 * Parse a campaign./*from w  ww . ja  va 2s  . c  o  m*/
 * @param campaignId already parsed campaign id.
 * @param values content data.
 * @throws JSONException if payload parsing failure.
 */
EngagementReachContent(com.microsoft.azure.engagement.reach.CampaignId campaignId, ContentValues values)
        throws JSONException {
    /* Parse base fields */
    mCampaignId = campaignId;
    mDlc = values.getAsInteger(DLC);
    mDlcId = values.getAsString(DLC_ID);
    mCategory = values.getAsString(CATEGORY);
    Long expiry = values.getAsLong(TTL);
    if (expiry != null) {
        expiry *= 1000L;
        if (parseBoolean(values, USER_TIME_ZONE))
            expiry -= TimeZone.getDefault().getOffset(expiry);
    }
    mExpiry = expiry;
    if (values.containsKey(PAYLOAD))
        setPayload(new JSONObject(values.getAsString(PAYLOAD)));
}

From source file:desmoj.extensions.grafic.util.Plotter.java

/**
* Constructor to set the path of output directory and the size of created image.
* Default are onScreen = false, locale = Locale.getDefault, timeZone = TimeZone.getdefault 
* @param path/* ww  w. jav a2s.c  om*/
* @param size
 */
public Plotter(String path, Dimension size) {
    this.paintPanel = new PaintPanel(path, size);
    this.onScreen = false;
    this.locale = Locale.getDefault();
    this.timeZone = TimeZone.getDefault();
    this.begin = null;
    this.end = null;
    this.frc = new FontRenderContext(new AffineTransform(), true, true);
}

From source file:com.bdb.weather.display.freeplot.FreePlotSeries.java

/**
 * Load the data for this series./* ww  w  .ja v  a2  s.co m*/
 * 
 * @param data A generic list on which the methods passed into the constructor will be called
 */
public void loadData(List<T> data) {
    series.setNotify(false);
    series.clear();
    data.stream().forEach((obj) -> {
        TemporalAccessor time = getTimeMethod.apply(obj);
        RegularTimePeriod period = RegularTimePeriod.createInstance(timePeriod,
                TimeUtils.localDateTimeToDate(time), TimeZone.getDefault());
        Measurement m;
        m = getDataMethod.apply(obj);
        if (m != null) {
            double value = m.get();
            series.add(period, value);
        }
    });
    series.fireSeriesChanged();
    series.setNotify(true);
}

From source file:com.microsoft.exchange.DateHelpTest.java

/**
 * Gets an {@link XMLGregorianCalendar} for the current date time using the default {@link TimeZone}
 * Test ensures the generated {@link XMLGregorianCalendar} has an offset which is equivalant to the default timezones rawOffSet + dstSavings
 * @throws DatatypeConfigurationException
 *///w w  w.java  2  s .  c  o m
@Test
public void getXMLGregorianCalendarNow() throws DatatypeConfigurationException {
    XMLGregorianCalendar xmlGregorianCalendarNow = DateHelp.getXMLGregorianCalendarNow();
    assertNotNull(xmlGregorianCalendarNow);
    int xmlTimeZoneOffsetMinutes = xmlGregorianCalendarNow.getTimezone();

    TimeZone xmlTimeZone = xmlGregorianCalendarNow.getTimeZone(xmlTimeZoneOffsetMinutes);
    assertNotNull(xmlTimeZone);

    TimeZone jvmTimeZone = TimeZone.getDefault();

    xmlGregorianCalendareMatchesTimeZone(xmlGregorianCalendarNow, jvmTimeZone);

}

From source file:com.redhat.rhn.common.util.RecurringEventPicker.java

/**
 * Constructor/*from w  w w . j  a  v a  2 s. c  o m*/
 * @param name0 the name
 */
public RecurringEventPicker(String name0) {
    name = name0;
    status = STATUS_DISABLED;
    dailyTimePicker = new DatePicker(name + "_" + STATUS_DAILY, TimeZone.getDefault(), Locale.getDefault(),
            DatePicker.YEAR_RANGE_POSITIVE);
    dailyTimePicker.setDisableDate();
    weeklyTimePicker = new DatePicker(name + "_" + STATUS_WEEKLY, TimeZone.getDefault(), Locale.getDefault(),
            DatePicker.YEAR_RANGE_POSITIVE);
    weeklyTimePicker.setDisableDate();
    monthlyTimePicker = new DatePicker(name + "_" + STATUS_MONTHLY, TimeZone.getDefault(), Locale.getDefault(),
            DatePicker.YEAR_RANGE_POSITIVE);
    monthlyTimePicker.setDisableDate();
}