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:org.jersey2.simple.jersey.ObjectMapperProvider.java

public ObjectMapperProvider() {
    this.objectMapper = new ObjectMapper();
    this.objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
    //set up ISO 8601 date/time stamp format:
    final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:sss'Z'");
    df.setTimeZone(TimeZone.getTimeZone("UTC"));
    this.objectMapper.setDateFormat(df);
}

From source file:com.ah.util.bo.starthere.NewStartHereForm.java

public String getCurrentTimeWithTimezone() {
    DATE_FORMAT.setTimeZone(TimeZone.getTimeZone(this.getTimeZone()));
    return DATE_FORMAT.format(new java.util.Date(System.currentTimeMillis()));
}

From source file:com.indoqa.lang.util.TimeUtilsTest.java

@Test
public void formatDate() {
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeZone(TimeZone.getTimeZone("GMT+1"));
    calendar.set(2012, 2, 1, 10, 5, 30);
    calendar.set(Calendar.MILLISECOND, 501);

    assertEquals("2012-03-01 09:05:30.501", TimeUtils.formatDate(calendar.getTime()));
}

From source file:org.springframework.social.bitbucket.api.impl.UTCDateDeserializer.java

@Override
public Date deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    try {/*from   w  ww . ja  v  a 2s .  co m*/
        SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH);
        dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
        return dateFormat.parse(jp.getText());
    } catch (ParseException e) {
        throw new JsonParseException("Can't parse date : " + jp.getText(), jp.getCurrentLocation());
    }
}

From source file:org.osgpfoundation.osgp.webdemoapp.application.config.WebDemoInitializer.java

@Override
public void onStartup(final ServletContext servletContext) throws ServletException {
    try {/* ww w. jav  a 2  s.  c om*/
        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

        final Context initialContext = new InitialContext();

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

        final ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME,
                new DispatcherServlet(rootContext));
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING);

        servletContext.addListener(new ContextLoaderListener(rootContext));
    } catch (final NamingException e) {
        throw new ServletException("naming exception", e);
    }
}

From source file:GmtCalendar.java

/**
 * Constructs a GmtCalendar with the given date set in the GMT time zone
 * with the default locale.//  w  w  w .  ja  v a  2s.co  m
 * 
 * @param year
 *            the value used to set the YEAR time field in the calendar.
 * @param month
 *            the value used to set the MONTH time field in the calendar.
 *            Month value is 0-based. e.g., 0 for January.
 * @param date
 *            the value used to set the DATE time field in the calendar.
 */

public GmtCalendar(int year, int month, int date) {

    super(TimeZone.getTimeZone("GMT"), Locale.getDefault());

    this.set(ERA, AD);

    this.set(YEAR, year);

    this.set(MONTH, month);

    this.set(DATE, date);

}

From source file:com.github.sourjson.translat.def.DateTranslater.java

/** */
public DateTranslater() {
    formater = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    formater.setTimeZone(TimeZone.getTimeZone("GMT"));
}

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

/**
 * convert user date to new date with server side Locale.
 * //www.jav a 2  s .c om
 * @param userTimeZone
 *            user TimeZone id
 * @param userDate
 *            date in user's Local
 * @return serverDate data in server's Local
 */
public static Date convertToServerDate(String userTimeZone, Date userDate) {
    TimeZone userLocal = TimeZone.getTimeZone(userTimeZone);
    int rawOffset = TimeZone.getDefault().getRawOffset() - userLocal.getRawOffset();
    return new Date(userDate.getTime() + rawOffset);
}

From source file:org.esigate.servlet.impl.HttpServletSessionTest.java

@Override
protected void setUp() throws Exception {
    format = new SimpleDateFormat(DateUtils.PATTERN_RFC1123, Locale.US);
    format.setTimeZone(TimeZone.getTimeZone("GMT"));
    super.setUp();
}

From source file:com.mothsoft.alexis.security.CurrentUserUtil.java

public static TimeZone getTimeZone() {
    // FIXME - make configurable somewhere
    return TimeZone.getTimeZone("America/Chicago");
}