List of usage examples for org.joda.time.chrono GJChronology getInstanceUTC
public static GJChronology getInstanceUTC()
From source file:com.helger.datetime.config.PDTConfig.java
License:Apache License
/** * @return The default chronology ({@link ISOChronology} or * {@link GJChronology}) with UTC date time zone. Never * <code>null</code>. * @see #isUseISOChronology()//w w w .j av a 2 s . c o m */ @Nonnull public static Chronology getDefaultChronologyUTC() { if (isUseISOChronology()) return ISOChronology.getInstanceUTC(); return GJChronology.getInstanceUTC(); }
From source file:com.phloc.datetime.config.PDTConfig.java
License:Apache License
/** * @return The default chronology with UTC date time zone *//*w ww.j a v a2 s.c o m*/ @Nonnull public static Chronology getDefaultChronologyUTC() { if (s_bUseISOChronology) return ISOChronology.getInstanceUTC(); return GJChronology.getInstanceUTC(); }
From source file:jp.furplag.util.time.DateTimeUtils.java
License:Apache License
/** * {@link org.joda.time.DateTimeUtils#toJulianDay(long)}. * <p>/*from ww w. ja v a 2s . co m*/ * Each day starts at midday (not midnight) and time is expressed as a fraction. * </p> * * @param instant the date-time object, null means current date-time. * @param strictly if true, returns null when the instant is invalid. * @return the astronomical julian day represented by the specified instant. */ public static Double toAJD(final Object instant, final boolean strictly) { DateTime then = getDateTime(instant, GJChronology.getInstanceUTC(), strictly); if (then == null) return null; return (then.getMillis() / MILLIS_OF_DAY) + MILLIS_PERIOD; }
From source file:jp.furplag.util.time.DateTimeUtils.java
License:Apache License
/** * {@link org.joda.time.DateTime#DateTime(Object, DateTimeZone)}. * * @param instant the date-time object, null means current date-time. * @param zone the time zone, null means UTC (NOT default) . * @param strictly if true, returns null when the instant is invalid. * @return {@link org.joda.time.DateTime#DateTime(Object, DateTimeZone)}. *///from w ww . jav a 2s . c o m private static DateTime getDateTime(final Object instant, final DateTimeZone zone, final boolean strictly) { if (strictly && instant == null) return null; if (instant == null) return DateTime.now(zone == null ? DateTimeZone.UTC : zone); Long millis = getMillis(instant, strictly); if (millis == null) return null; try { if (millis > GREGORIAN_CUTOVER) return new DateTime((long) millis, zone == null ? DateTimeZone.UTC : zone); return new DateTime((long) millis, zone == null ? GJChronology.getInstanceUTC() : GJChronology.getInstance(zone)); } catch (Exception e) { } if (strictly) return null; return DateTime.now(zone == null ? DateTimeZone.UTC : zone); }
From source file:jp.furplag.util.time.DateTimeUtils.java
License:Apache License
/** * {@link org.joda.time.DateTime#getMillis()}. * * @param instant the date-time object, null means current date-time. * @param strictly if true, returns null when the instant is invalid. * @return {@link org.joda.time.DateTime#getMillis()}. *//* w w w . j ava 2 s. c o m*/ private static Long getMillis(final Object instant, final boolean strictly) { if (instant instanceof DateTime) return ((DateTime) instant).getMillis(); if (instant != null && ObjectUtils.isAny(ClassUtils.primitiveToWrapper(instant.getClass()), BigDecimal.class, Double.class, Float.class)) { if (isInfiniteOrNaN(valueOf(instant, double.class))) return null; return fromJD(valueOf(instant, double.class)); } if (instant != null && ObjectUtils.isAny(ClassUtils.primitiveToWrapper(instant.getClass()), BigInteger.class, Byte.class, Short.class, Integer.class, Long.class)) { return valueOf(instant, long.class); } try { return new DateTime(instant, GJChronology.getInstanceUTC()).getMillis(); } catch (Exception e) { } if (strictly) return null; return DateTime.now().getMillis(); }