Example usage for java.util TimeZone getTimeZone

List of usage examples for java.util TimeZone getTimeZone

Introduction

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

Prototype

public static TimeZone getTimeZone(ZoneId zoneId) 

Source Link

Document

Gets the TimeZone for the given zoneId .

Usage

From source file:com.google.orkut.client.api.Util.java

static String getFormattedTimestamp(long timeMillis) {
    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(Constants.DateFormatter.UTC));
    cal.setTimeInMillis(timeMillis);/*from w  w w .  ja va  2s  . com*/
    StringBuilder date = new StringBuilder();
    date.append(cal.get(Calendar.YEAR));
    date.append(Constants.DateFormatter.DATE_SEPARATOR);
    date.append(padSingleDigitNum(cal.get(Calendar.MONTH) + 1));
    date.append(Constants.DateFormatter.DATE_SEPARATOR);
    date.append(padSingleDigitNum(cal.get(Calendar.DATE)));
    date.append(Constants.DateFormatter.DATE_DELIM);
    date.append(padSingleDigitNum(cal.get(Calendar.HOUR)));
    date.append(Constants.DateFormatter.TIME_SEPARATOR);
    date.append(padSingleDigitNum(cal.get(Calendar.MINUTE)));
    date.append(Constants.DateFormatter.TIME_SEPARATOR);
    date.append(padSingleDigitNum(cal.get(Calendar.SECOND)));
    date.append(Constants.DateFormatter.TIME_DELIM);
    return date.toString();
}

From source file:net.solarnetwork.node.reactor.io.json.JsonReactorSerializationService.java

private static ObjectMapper defaultObjectMapper() {
    ObjectMapper mapper = new ObjectMapper();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS'Z'");
    sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
    mapper.setDateFormat(sdf);/* www  .  j a  v a2  s . com*/
    return mapper;
}

From source file:com.github.shredder121.testannotations.timezone.TimeZoneRule.java

private static TimeZone getTimeZoneLegacy(String id) {
    return TimeZone.getTimeZone(id);
}

From source file:eu.domibus.ebms3.common.TimestampDateFormatter.java

public String generateTimestamp() {
    this.xmlDateTimeFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

    return this.xmlDateTimeFormat.format(new Date());
}

From source file:jenkins.model.RunIdMigratorTest.java

/** Ensures that legacy timestamps are interpreted in a predictable time zone. */
@BeforeClass/*w w  w. j  a v a 2  s. co  m*/
public static void timezone() {
    TimeZone.setDefault(TimeZone.getTimeZone("EST"));
}

From source file:Main.java

private static TimeZone safeTimeZone(String s) {
    String tzid = tzid(s);/* w  w w  .j a v a  2  s .  c  om*/
    if (tzid == null)
        return null;

    TimeZone tz = cachedTimeZone;
    if (tz == null || !tz.getID().equals(tzid))
        cachedTimeZone = tz = TimeZone.getTimeZone(tzid);

    return tz;
}

From source file:groovyx.gaelyk.graelyk.cast.TimeZoneEditor.java

public void setAsText(String text) throws IllegalArgumentException {
    if (StringUtils.isBlank(text)) {
        setValue(null);/*from w ww  . j  a  v a2 s  .  c o  m*/
    }
    try {
        setValue(TimeZone.getTimeZone(text));
    } catch (IllegalArgumentException e) {
        // ignore and just set to null
        setValue(null);
    }
}

From source file:com.yahoo.elide.utils.coerce.converters.ISO8601DateSerde.java

public ISO8601DateSerde() {
    this("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC"));
}

From source file:de.dentrassi.pm.jenkins.AbstractUploader.java

public AbstractUploader(final RunData runData) {
    this.runData = runData;
    this.sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    this.sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
}

From source file:io.soabase.core.rest.SoaApis.java

@GET
@Produces(MediaType.APPLICATION_JSON)/*from  w ww .jav  a  2  s . c om*/
public Info getInfo() {
    TimeZone tz = TimeZone.getTimeZone("UTC");
    ISO8601DateFormat df = new ISO8601DateFormat();
    df.setTimeZone(tz);
    String now = df.format(new Date());
    String start = df.format(new Date(soaInfo.getStartTimeMs()));
    return new Info(soaInfo.getScopes(), soaInfo.getMainPort(), soaInfo.getAdminPort(),
            soaInfo.getServiceName(), soaInfo.getInstanceName(), start, now);
}