OffsetDateTime withOffsetSameLocal(ZoneOffset offset) example
Description
OffsetDateTime withOffsetSameLocal(ZoneOffset offset)
returns a copy of this OffsetDateTime with the specified offset
ensuring that the result has the same local date-time.
Syntax
withOffsetSameLocal
has the following syntax.
public OffsetDateTime withOffsetSameLocal(ZoneOffset offset)
Example
The following example shows how to use withOffsetSameLocal
.
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
//from w ww . j av a 2s . c o m
public class Main {
public static void main(String[] args) {
OffsetDateTime o = OffsetDateTime.now();
OffsetDateTime l = o.withOffsetSameLocal(ZoneOffset.UTC);
System.out.println(l);
}
}
The code above generates the following result.