Example usage for org.joda.time DateTimeZone getDefault

List of usage examples for org.joda.time DateTimeZone getDefault

Introduction

In this page you can find the example usage for org.joda.time DateTimeZone getDefault.

Prototype

public static DateTimeZone getDefault() 

Source Link

Document

Gets the default time zone.

Usage

From source file:org.cleverbus.common.jaxb.JaxbDateAdapter.java

License:Apache License

@Nullable
public static DateTime parseDate(@Nullable String dateStr) {
    if (dateStr == null) {
        return null;
    }//www .  j a v  a2s .  co  m

    return new DateTime(DatatypeConverter.parseDate(dateStr), DateTimeZone.getDefault());
}

From source file:org.cleverbus.common.jaxb.JaxbDateAdapter.java

License:Apache License

@Nullable
public static DateTime parseDateTime(@Nullable String dtStr) {
    if (dtStr == null) {
        return null;
    }/*from   w  ww.j  a  v  a 2 s .c  om*/

    return DateTime.parse(dtStr).withZone(DateTimeZone.getDefault());
}

From source file:org.cleverbus.common.jaxb.JaxbDateAdapter.java

License:Apache License

@Nullable
public static String printDateTime(@Nullable DateTime dt) {
    if (dt == null) {
        return null;
    }/*from   w w  w.  ja  v  a2  s  .  c o m*/

    return dt.withZone(DateTimeZone.getDefault()).toString(ISODateTimeFormat.dateTime());
}

From source file:org.cleverbus.common.Tools.java

License:Apache License

/**
 * Converts UTC instant of {@link DateTime} to local instant of {@link DateTime} with default time zone.
 *
 * @param utcTime the UTC time/*w  ww .j a v  a2s.  co  m*/
 * @return the local time
 */
public static DateTime fromUTC(DateTime utcTime) {
    DateTimeZone dateTimeZone = DateTimeZone.getDefault();
    long localTime = dateTimeZone.convertUTCToLocal(utcTime.getMillis());
    return new DateTime(localTime, dateTimeZone);
}

From source file:org.cleverbus.common.Tools.java

License:Apache License

/**
 * Converts UTC time in millis to local {@link DateTime} with default time zone.
 *
 * @param utcMillis the UTC time in millis
 * @return the local time/*from  w  w w.  j a v a  2  s .c o  m*/
 */
public static DateTime fromUTC(long utcMillis) {
    DateTimeZone dateTimeZone = DateTimeZone.getDefault();
    long localTime = dateTimeZone.convertUTCToLocal(utcMillis);
    return new DateTime(localTime, dateTimeZone);
}

From source file:org.dalesbred.integration.joda.JodaTypeConversions.java

License:Open Source License

public static void register(@NotNull TypeConversionRegistry typeConversionRegistry) {
    typeConversionRegistry.registerConversions(Timestamp.class, DateTime.class, DateTime::new,
            v -> new Timestamp(v.getMillis()));

    typeConversionRegistry.registerConversionFromDatabase(java.util.Date.class, LocalDate.class,
            LocalDate::fromDateFields);
    typeConversionRegistry.registerConversionFromDatabase(Time.class, LocalTime.class, LocalTime::new);
    typeConversionRegistry.registerConversionFromDatabase(String.class, DateTimeZone.class,
            DateTimeZone::forID);/*from   w w  w.  j  a va2s  .  c o m*/

    typeConversionRegistry.registerConversionToDatabase(LocalDate.class,
            value -> new Date(value.toDateTimeAtStartOfDay().getMillis()));
    typeConversionRegistry.registerConversionToDatabase(LocalTime.class,
            value -> new Time(value.toDateTimeToday(DateTimeZone.getDefault()).getMillis()));
    typeConversionRegistry.registerConversionToDatabase(DateTimeZone.class, DateTimeZone::getID);
}

From source file:org.drftpd.commands.tvmaze.TvMazeConfig.java

License:Open Source License

private void loadConfig() {
    Properties cfg = GlobalContext.getGlobalContext().getPluginsConfig().getPropertiesForPlugin("tvmaze.conf");
    if (cfg == null) {
        logger.fatal("conf/plugins/tvmaze.conf not found");
        return;/*from ww  w  .ja  v a2s  .co m*/
    }
    _filters.clear();
    for (int i = 1;; i++) {
        String filter = cfg.getProperty("filter." + i);
        if (filter == null)
            break;
        _filters.add(filter);
    }
    _date = cfg.getProperty("date.show", "yyyy-MM-dd");
    _time = cfg.getProperty("time.show", "EEEE, HH:mm");
    _dtz = cfg.getProperty("timezone") == null ? DateTimeZone.getDefault()
            : DateTimeZone.forID(cfg.getProperty("timezone"));
    _exclude = cfg.getProperty("exclude", "");
    addSectionsFromConf(cfg, "race.section.", _rSections);
    addSectionsFromConf(cfg, "search.sd.section.", _sSDSections);
    addSectionsFromConf(cfg, "search.hd.section.", _sHDSections);
    _sRelease = cfg.getProperty("search.release", "false").equalsIgnoreCase("true");
    _startDelay = Integer.parseInt(cfg.getProperty("delay.start", "5"));
    _endDelay = Integer.parseInt(cfg.getProperty("delay.end", "10"));
    if (_startDelay >= _endDelay) {
        logger.warn("Start delay >= End delay, setting default values 5-10");
        _startDelay = 0;
        _endDelay = 5;
    }
    _bar_enabled = cfg.getProperty("tvmazebar.enabled", "true").equalsIgnoreCase("true");
    _bar_directory = cfg.getProperty("tvmazebar.directory", "true").equalsIgnoreCase("true");
}

From source file:org.encuestame.mvc.interceptor.EnMeSecurityInterceptor.java

License:Apache License

public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
        ModelAndView modelAndView) throws Exception {
    //log.trace("postHandle");
    Cookie cookieName = WebUtils.getCookie(request, this.COOKIE_NAME);
    if (cookieName == null) {
        createAddCookie(COOKIE_NAME, response, RandomStringUtils.random(4));
    }/*w  ww.  ja  v  a 2  s. c om*/
    Cookie cookieLanguage = WebUtils.getCookie(request, this.COOKIE_LANGUAGE);
    if (cookieLanguage == null) {
        createAddCookie(COOKIE_LANGUAGE, response, request.getLocale().toString());
    }
    Cookie cookieTimeZone = WebUtils.getCookie(request, this.COOKIE_TIMEZONE);
    if (cookieTimeZone == null) {
        createAddCookie(COOKIE_TIMEZONE, response, DateTimeZone.getDefault().toTimeZone().toString());
    }
    Cookie cookieContext = WebUtils.getCookie(request, this.COOKIE_CONTEXT);
    if (cookieContext == null) {
        createAddCookie(COOKIE_CONTEXT, response, request.getContextPath());
    }
}

From source file:org.epics.archiverappliance.common.TimeUtils.java

public static String convertToHumanReadableString(java.sql.Timestamp ts) {
    if (ts == null || ts.getTime() == 0)
        return "Never";
    DateTimeFormatter fmt = DateTimeFormat.forPattern("MMM/dd/yyyy HH:mm:ss z");
    DateTime dateTime = new DateTime(ts.getTime(), DateTimeZone.getDefault());
    String retval = fmt.print(dateTime);
    return retval;
}

From source file:org.epics.archiverappliance.common.TimeUtils.java

public static String convertToHumanReadableString(long epochSeconds) {
    if (epochSeconds == 0)
        return "Never";
    DateTimeFormatter fmt = DateTimeFormat.forPattern("MMM/dd/yyyy HH:mm:ss z");
    DateTime dateTime = new DateTime(epochSeconds * 1000, DateTimeZone.getDefault());
    String retval = fmt.print(dateTime);
    return retval;
}