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:de.javakaffee.web.msm.serializer.javolution.JodaDateTimeFormat.java

License:Apache License

private DateTimeZone readTimeZone(final javolution.xml.XMLFormat.InputElement input) throws XMLStreamException {
    final CharArray tz = input.getAttribute(TIME_ZONE);
    return tz != null ? DateTimeZone.forID(tz.toString()) : DateTimeZone.getDefault();
}

From source file:de.javakaffee.web.msm.serializer.javolution.JodaDateTimeFormat.java

License:Apache License

/**
 * {@inheritDoc}//from  ww  w  .j a  va2  s.  c  o m
 */
@Override
public void write(final DateTime obj, final javolution.xml.XMLFormat.OutputElement output)
        throws XMLStreamException {
    output.setAttribute(MILLIS, obj.getMillis());
    final String chronologyId = getChronologyId(obj.getChronology());
    if (chronologyId != null) {
        output.setAttribute(CHRONOLOGY, chronologyId);
    }
    if (obj.getZone() != null && obj.getZone() != DateTimeZone.getDefault()) {
        output.setAttribute(TIME_ZONE, obj.getZone().getID());
    }
}

From source file:de.kuschku.libquassel.primitives.serializers.DateTimeSerializer.java

License:Open Source License

@Override
public void serialize(@NonNull final ByteChannel channel, @NonNull final DateTime data) throws IOException {
    final boolean isUTC;
    final DateTimeZone zone = data.getZone();
    if (Objects.equals(zone, DateTimeZone.UTC)) {
        isUTC = true;/* www .  j  a v  a2  s  .c om*/
    } else if (Objects.equals(zone, DateTimeZone.getDefault())) {
        isUTC = false;
        // TODO: Add serialization for other timezones
    } else {
        throw new IllegalArgumentException(
                "Serialization of timezones except for local and UTC is not supported");
    }

    IntSerializer.get().serialize(channel, (int) DateTimeUtils.toJulianDayNumber(data.getMillis()));
    IntSerializer.get().serialize(channel, data.getMillisOfDay());
    BoolSerializer.get().serialize(channel, isUTC);
}

From source file:de.kuschku.libquassel.primitives.serializers.DateTimeSerializer.java

License:Open Source License

@NonNull
@Override/*  w ww  .j a  va2 s .c om*/
public DateTime deserialize(@NonNull final ByteBuffer buffer) throws IOException {
    final long julianDay = IntSerializer.get().deserialize(buffer);
    final int millisSinceMidnight = IntSerializer.get().deserialize(buffer);

    final short zone = ByteSerializer.get().deserialize(buffer);

    if (millisSinceMidnight == 0x73007300 && julianDay == 0x50006100 || millisSinceMidnight == -1
            || julianDay == -1)
        return new DateTime(0);

    if ((zone & 0xfffffff0) > 0) {
        throw new IllegalArgumentException(
                "Deserialization of timezones except for local and UTC is not supported: " + zone);
    }

    DateTime time = new DateTime(DateTimeUtils.fromJulianDay(julianDay));
    time = time.millisOfDay().setCopy(millisSinceMidnight);
    if (zone == 0)
        time = time.withZone(DateTimeZone.getDefault());
    else
        time = time.withZone(DateTimeZone.UTC);

    return time;
}

From source file:debop4k.data.mybatis.typehandlers.joda.JodaLocalDateToDateTypeHandler.java

License:Apache License

private LocalDate asLocalDate(Date date) {
    if (date != null)
        return new LocalDate(date.getTime(), DateTimeZone.getDefault());
    return null;/*from  w  w w.  j av a  2 s  .c o m*/
}

From source file:divconq.hub.Clock.java

License:Open Source License

public Clock() {
    this.serverTimeZone = DateTimeZone.getDefault();
}

From source file:divconq.lang.op.OperationContextBuilder.java

License:Open Source License

public OperationContextBuilder withGuestUserTemplate() {
    return this.withDomainId("00000_000000000000001") // guest is part of root domain
            .withUserId("00000_000000000000002").withUsername("guest").withFullName("Guest User")
            .withVerified(true).withAuthTags("Guest").withLocale(LocaleUtil.getDefaultLocale())
            .withChronology("/" + DateTimeZone.getDefault().getID()); // ISOChronology w/ default zone
}

From source file:divconq.lang.op.OperationContextBuilder.java

License:Open Source License

public OperationContextBuilder withRootUserTemplate() {
    return this.withDomainId("00000_000000000000001") // root is part of root domain
            .withUserId("00000_000000000000001").withUsername("root").withFullName("Root User")
            .withVerified(true).withAuthTags("User", "PowerUser", "Admin", "SysAdmin")
            .withLocale(LocaleUtil.getDefaultLocale()).withChronology("/" + DateTimeZone.getDefault().getID()); // ISOChronology w/ default zone
}

From source file:divconq.util.TimeUtil.java

License:Open Source License

/**
 * try to lookup a timezone, but use default if it fails 
 * //www.  j av  a 2s.c  o m
 * @param zoneId id of the timezone desired
 * @return timezone to use
 */
static public DateTimeZone selectZone(String zoneId) {
    DateTimeZone zone = DateTimeZone.getDefault();

    try {
        if (StringUtil.isNotEmpty(zoneId))
            zone = DateTimeZone.forID(zoneId);
    } catch (Exception x) {
    }

    return zone;
}

From source file:divconq.util.TimeUtil.java

License:Open Source License

/**
 * get the DST start transition for a given year
 * //w  w w. j  a va 2  s  . co m
 * @param year the year to use, e.g. 2012
 * @return datetime of the start transition
 */
public static DateTime startDST(int year) {
    DateTimeZone zone = DateTimeZone.getDefault();
    return new DateTime(zone.nextTransition(new DateTime(year, 1, 1, 0, 0, 0, 0, zone).getMillis()));
}