Example usage for org.joda.time DateTime withZone

List of usage examples for org.joda.time DateTime withZone

Introduction

In this page you can find the example usage for org.joda.time DateTime withZone.

Prototype

public DateTime withZone(DateTimeZone newZone) 

Source Link

Document

Returns a copy of this datetime with a different time zone, preserving the millisecond instant.

Usage

From source file:com.microsoft.rest.serializer.DateTimeSerializer.java

License:Open Source License

@Override
public void serialize(DateTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
    if (provider.isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)) {
        jgen.writeNumber(value.getMillis());
    } else {/*from  w  ww  .  ja v  a  2 s  .  co m*/
        value = value.withZone(DateTimeZone.UTC);
        jgen.writeString(value.toString(ISODateTimeFormat.dateTime()));
    }
}

From source file:com.mycollab.core.utils.DateTimeUtils.java

License:Open Source License

/**
 * Convert from UTC time to default time zone of system
 *
 * @param timeInMillis/*w w  w. ja v  a2s. c o  m*/
 * @return
 */
public static Date convertTimeFromUTCToSystemTimezone(long timeInMillis) {
    DateTime dt = new DateTime();
    dt = dt.withMillis(DateTimeZone.getDefault().getOffset(timeInMillis) + timeInMillis);
    dt = dt.withZone(utcZone);
    return dt.toDate();
}

From source file:com.netflix.raigad.backup.S3Repository.java

License:Apache License

@Override
public String getRemoteRepositoryName() {
    DateTime dt = new DateTime();
    DateTime dtGmt = dt.withZone(currentZone);
    return SystemUtils.formatDate(dtGmt, S3_REPO_DATE_FORMAT);
}

From source file:com.netflix.raigad.backup.S3RepositorySettingsParams.java

License:Apache License

public String getS3RepositoryName() {
    DateTime dt = new DateTime();
    DateTime dtGmt = dt.withZone(DateTimeZone.UTC);
    return formatDate(dtGmt, S3_REPO_DATE_FORMAT);
}

From source file:com.netflix.raigad.backup.SnapshotBackupManager.java

License:Apache License

public String getSnapshotName(String indices, boolean includeIndexNameInSnapshot) {
    StringBuilder snapshotName = new StringBuilder();
    if (includeIndexNameInSnapshot) {
        String indexName;//from   w  ww . j av a  2 s.c  o  m
        if (indices.toLowerCase().equals("all"))
            indexName = "all";
        else
            indexName = StringUtils.replace(indices, ",", "_");
        snapshotName.append(indexName).append("_");
    }

    DateTime dt = new DateTime();
    DateTime dtGmt = dt.withZone(currentZone);
    String snapshotDate = SystemUtils.formatDate(dtGmt, S3_REPO_FOLDER_DATE_FORMAT);
    snapshotName.append(snapshotDate);
    return snapshotName.toString();
}

From source file:com.robwilliamson.healthyesther.fragment.dialog.AbstractDateTimePickerFragment.java

License:Open Source License

public void setDateTime(DateTime dateTime) {
    mDateTime = dateTime.withZone(DateTimeZone.forTimeZone(TimeZone.getDefault()));
}

From source file:com.robwilliamson.healthyesther.reminder.TimingManager.java

License:Open Source License

private static DateTime makeLocal(DateTime time) {
    if (time == null) {
        return null;
    }//  ww  w  .  j  a  va2  s. c o m

    return time.withZone(DateTimeZone.forTimeZone(TimeZone.getDefault()));
}

From source file:com.ryan.ryanreader.common.RRTime.java

License:Open Source License

public static String formatDateTime(final long utc_ms, final Context context) {

    final DateTime dateTime = new DateTime(utc_ms);
    final DateTime localDateTime = dateTime.withZone(DateTimeZone.getDefault());

    if (DateFormat.is24HourFormat(context)) {
        return dtFormatter24hr.print(localDateTime);
    } else {/*from  w ww  . j  av  a 2s. c o  m*/
        return dtFormatter12hr.print(localDateTime);
    }
}

From source file:com.solidfire.core.serialization.DateTimeAdapter.java

License:Open Source License

/**
 * Writes a DateTime object.//from   ww w. j ava2 s .com
 *
 * @param writer the JSON writer to write to.
 * @param value  the DateTime object to write.
 * @throws IOException
 */
@Override
public void write(JsonWriter writer, DateTime value) throws IOException {
    if (value == null) {
        writer.nullValue();
    } else {
        DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
        writer.value(fmt.print(value.withZone(DateTimeZone.UTC)));
    }
}

From source file:com.sonicle.webtop.calendar.bol.model.ReminderGenId.java

License:Open Source License

public static String buildId(DateTime remindOn) {
    return Hex.encodeHexString(remindOn.withZone(DateTimeZone.UTC).toString().getBytes());
}