List of usage examples for java.util GregorianCalendar toZonedDateTime
public ZonedDateTime toZonedDateTime()
From source file:Main.java
public static void main(String[] args) { GregorianCalendar gregorianCalendar = new GregorianCalendar(); ZonedDateTime d = gregorianCalendar.toZonedDateTime(); System.out.println(d);//from ww w .jav a2 s. c o m }
From source file:Main.java
public static void main(String[] args) { GregorianCalendar gc = new GregorianCalendar(2014, 1, 11, 15, 45, 50); LocalDate ld = gc.toZonedDateTime().toLocalDate(); System.out.println("Local Date: " + ld); LocalTime lt = gc.toZonedDateTime().toLocalTime(); System.out.println("Local Time: " + lt); LocalDateTime ldt = gc.toZonedDateTime().toLocalDateTime(); System.out.println("Local DateTime: " + ldt); OffsetDateTime od = gc.toZonedDateTime().toOffsetDateTime(); System.out.println("Offset Date: " + od); OffsetTime ot = gc.toZonedDateTime().toOffsetDateTime().toOffsetTime(); System.out.println("Offset Time: " + ot); ZonedDateTime zdt = gc.toZonedDateTime(); System.out.println("Zoned DateTime: " + zdt); ZoneId zoneId = zdt.getZone(); TimeZone timeZone = TimeZone.getTimeZone(zoneId); System.out.println("Zone ID: " + zoneId); System.out.println("Time Zone ID: " + timeZone.getID()); GregorianCalendar gc2 = GregorianCalendar.from(zdt); System.out.println("Gregorian Calendar: " + gc2.getTime()); }
From source file:com.hybridbpm.core.util.HybridbpmCoreUtil.java
public static LocalDateTime toLocalDateTime(Date date) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(date);//from w ww . j av a 2 s. c o m ZonedDateTime zdt = cal.toZonedDateTime(); return zdt.toLocalDateTime(); }
From source file:org.eclipse.smarthome.binding.astro.internal.util.PropertyUtils.java
/** * Returns the state of the channel./*from w ww. jav a2s. c o m*/ */ public static State getState(ChannelUID channelUID, AstroChannelConfig config, Object instance) throws Exception { Object value = getPropertyValue(channelUID, instance); if (value == null) { return UnDefType.UNDEF; } else if (value instanceof State) { return (State) value; } else if (value instanceof Calendar) { Calendar cal = (Calendar) value; GregorianCalendar gregorianCal = (GregorianCalendar) DateTimeUtils.applyConfig(cal, config); cal.setTimeZone(TimeZone.getTimeZone(timeZoneProvider.getTimeZone())); ZonedDateTime zoned = gregorianCal.toZonedDateTime().withFixedOffsetZone(); return new DateTimeType(zoned); } else if (value instanceof Number) { BigDecimal decimalValue = new BigDecimal(value.toString()).setScale(2, RoundingMode.HALF_UP); return new DecimalType(decimalValue); } else if (value instanceof String || value instanceof Enum) { return new StringType(value.toString()); } else { throw new IllegalStateException("Unsupported value type " + value.getClass().getSimpleName()); } }