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:iddb.web.viewbean.NoticeViewBean.java

@Override
public String toString() {
    StringBuilder s = new StringBuilder();
    DateFormat format = new SimpleDateFormat("dd/MM/yyyy");
    format.setTimeZone(TimeZone.getTimeZone("GMT-3"));

    s.append(getReason()).append(". ");
    s.append("Agregado el ").append(format.format(this.getCreated()));
    if (StringUtils.isNotEmpty(this.getAdmin())) {
        s.append(" por ").append(getAdmin());
    }//from   w  ww  .j a  v a2s .  c  o  m
    return s.toString();
}

From source file:elt.generaltest.TmpTest.java

@Test
public void timestamptest() {
    Long longval = 1463288494L;/*from   www .j  a v a  2s.c  o m*/
    String str = DateFormatUtils.format(longval * 1000, "yyyy-MM-dd'T'HH:mm:ssZZ",
            TimeZone.getTimeZone("America/Los_Angeles"));
    System.out.println(str);
}

From source file:com.alliander.osgp.signing.server.application.config.SigningServerInitializer.java

@Override
public void onStartup(final ServletContext servletContext) throws ServletException {
    try {//  w  ww.j  av  a 2 s  .  c o  m
        // Force the timezone of application to UTC (required for
        // Hibernate/JDBC)
        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

        final Context initialContext = new InitialContext();

        final String logLocation = (String) initialContext.lookup("java:comp/env/osp/signingServer/log-config");
        LogbackConfigurer.initLogging(logLocation);

        final AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
        rootContext.register(ApplicationContext.class);

        servletContext.addListener(new ContextLoaderListener(rootContext));

    } catch (final NamingException e) {
        throw new ServletException("Naming exception", e);
    } catch (final FileNotFoundException e) {
        throw new ServletException("Logging file not found", e);
    } catch (final JoranException e) {
        throw new ServletException("Logback exception", e);
    }
}

From source file:io.seldon.spark.actions.JobUtils.java

public static long utc_to_unixts(String utc_date) throws ParseException {
    DateFormat utcFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    utcFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

    Date date = utcFormat.parse(utc_date);
    return (date.getTime() / 1000);
}

From source file:org.osgp.adapter.protocol.dlms.application.config.ProtocolAdapterDlmsInitializer.java

@Override
public void onStartup(final ServletContext servletContext) throws ServletException {
    try {/*  w ww.  j a v a 2 s  . co m*/
        // Force the timezone of application to UTC (required for
        // Hibernate/JDBC)
        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

        final Context initialContext = new InitialContext();

        final String logLocation = (String) initialContext
                .lookup("java:comp/env/osp/osgpAdapterProtocolDlms/log-config");
        LogbackConfigurer.initLogging(logLocation);

        final AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
        rootContext.register(ApplicationContext.class);

        servletContext.addListener(new ContextLoaderListener(rootContext));

    } catch (final NamingException e) {
        throw new ServletException("naming exception", e);
    } catch (final FileNotFoundException e) {
        throw new ServletException("Logging file not found", e);
    } catch (final JoranException e) {
        throw new ServletException("Logback exception", e);
    }
}

From source file:io.soabase.core.SoaInfo.java

public static DateFormat newUtcFormatter() {
    TimeZone tz = TimeZone.getTimeZone("UTC");
    ISO8601DateFormat df = new ISO8601DateFormat();
    df.setTimeZone(tz);//from   w w w .  j ava 2  s  .  c om
    return df;
}

From source file:net.netheos.pcsapi.providers.hubic.SwiftTest.java

@Test
public void testParseTimestamp() {
    // Check we won't break if a header is missing :
    Headers headers = new Headers();
    Date timestamp = Swift.parseTimestamp(headers);
    assertNull(timestamp);/*from  w  w w. j a  v  a 2s.c o m*/

    headers.addHeader("X-Timestamp", "1383925113.43900"); // 2013-11-08T16:38:33.439+01:00
    timestamp = Swift.parseTimestamp(headers);

    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    cal.setTime(timestamp);
    System.out.println(timestamp);
    assertEquals(2013, cal.get(Calendar.YEAR));
    assertEquals(Calendar.NOVEMBER, cal.get(Calendar.MONTH));
    assertEquals(8, cal.get(Calendar.DAY_OF_MONTH));
    assertEquals(15, cal.get(Calendar.HOUR_OF_DAY));
    assertEquals(38, cal.get(Calendar.MINUTE));
    assertEquals(33, cal.get(Calendar.SECOND));
    assertEquals(439, cal.get(Calendar.MILLISECOND));

    checkTimestamp("1383925113.430723", new Date(1383925113430L));
    checkTimestamp("1383925113.43900", new Date(1383925113439L));
    checkTimestamp("1383925113.439", new Date(1383925113439L));
    checkTimestamp("1383925113.43", new Date(1383925113430L));
    checkTimestamp("1383925113.4", new Date(1383925113400L));
    checkTimestamp("1383925113.", new Date(1383925113000L));
    checkTimestamp("1383925113", new Date(1383925113000L));
}

From source file:com.alliander.osgp.adapter.protocol.oslp.application.config.OsgpProtocolAdapterOslpInitializer.java

@Override
public void onStartup(final ServletContext servletContext) throws ServletException {
    try {/*from  w ww .ja va2s  . c om*/
        // Force the timezone of application to UTC (required for
        // Hibernate/JDBC)
        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

        final Context initialContext = new InitialContext();

        final String logLocation = (String) initialContext
                .lookup("java:comp/env/osp/osgpAdapterProtocolOslp/log-config");
        LogbackConfigurer.initLogging(logLocation);

        final AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
        rootContext.register(ApplicationContext.class);

        servletContext.addListener(new ContextLoaderListener(rootContext));

    } catch (final NamingException e) {
        throw new ServletException("naming exception", e);
    } catch (final FileNotFoundException e) {
        throw new ServletException("Logging file not found", e);
    } catch (final JoranException e) {
        throw new ServletException("Logback exception", e);
    }
}

From source file:com.alliander.osgp.adapter.protocol.oslp.elster.application.config.OsgpProtocolAdapterOslpInitializer.java

@Override
public void onStartup(final ServletContext servletContext) throws ServletException {
    try {//from   w w w.  j  av  a2s  .  co  m
        // Force the timezone of application to UTC (required for
        // Hibernate/JDBC)
        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

        final Context initialContext = new InitialContext();

        final String logLocation = (String) initialContext
                .lookup("java:comp/env/osp/osgpAdapterProtocolOslpElster/log-config");
        LogbackConfigurer.initLogging(logLocation);

        final AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
        rootContext.register(ApplicationContext.class);

        servletContext.addListener(new ContextLoaderListener(rootContext));

    } catch (final NamingException e) {
        throw new ServletException("naming exception", e);
    } catch (final FileNotFoundException e) {
        throw new ServletException("Logging file not found", e);
    } catch (final JoranException e) {
        throw new ServletException("Logback exception", e);
    }
}

From source file:com.alliander.osgp.adapter.protocol.iec61850.application.config.OsgpProtocolAdapterIec61850Initializer.java

@Override
public void onStartup(final ServletContext servletContext) throws ServletException {
    try {//w w w .j av  a  2 s  .  com
        // Force the timezone of application to UTC (required for
        // Hibernate/JDBC)
        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

        final Context initialContext = new InitialContext();

        final String logLocation = (String) initialContext
                .lookup("java:comp/env/osp/osgpAdapterProtocolIec61850/log-config");
        LogbackConfigurer.initLogging(logLocation);

        final AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
        rootContext.register(ApplicationContext.class);

        servletContext.addListener(new ContextLoaderListener(rootContext));

    } catch (final NamingException e) {
        throw new ServletException("naming exception", e);
    } catch (final FileNotFoundException e) {
        throw new ServletException("Logging file not found", e);
    } catch (final JoranException e) {
        throw new ServletException("Logback exception", e);
    }
}