Example usage for org.joda.time DateTimeZone getOffsetFromLocal

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

Introduction

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

Prototype

public int getOffsetFromLocal(long instantLocal) 

Source Link

Document

Gets the millisecond offset to subtract from local time to get UTC time.

Usage

From source file:com.enonic.cms.business.timezone.TimeZoneXmlCreator.java

License:Open Source License

private Element doCreateTimeZoneElement(DateTimeZone timeZone) {

    Element timeZoneEl = new Element("time-zone");
    timeZoneEl.setAttribute("ID", timeZone.getID());
    timeZoneEl.addContent(new Element("display-name").setText(timeZone.getID()));

    DateTime localTime = now.plus(timeZone.getOffsetFromLocal(now.getMillis()));
    Period offsetPeriod = new Period(now, localTime);
    //timeZoneEl.addContent( new Element( "hours-from-utc" ).setText( String.valueOf( offsetPeriod.getHours() ) ) );
    timeZoneEl.addContent(// w ww.j  av a 2s .c o m
            new Element("hours-from-utc-as-human-readable").setText(getHoursAsHumanReadable(offsetPeriod)));

    return timeZoneEl;
}