Package org.joda.time

Examples of org.joda.time.Instant


  }

  @Test
  public void testPartitionFieldConstraints() {
    GenericEvent e = new GenericEvent();
    DateTime eventDateTime = new Instant(e.getTimestamp())
        .toDateTime(DateTimeZone.UTC);

    // these constraints are for partition fields
    Constraints eventDay = emptyConstraints
        .with("year", eventDateTime.getYear())
View Full Code Here


  }

  @Test
  public void testPartitionFieldConstraintsMinimized() {
    GenericEvent e = new GenericEvent();
    DateTime eventDateTime = new Instant(e.getTimestamp())
        .toDateTime(DateTimeZone.UTC);

    // year and month constraints are for partition fields
    Constraints green = emptyConstraints
        .from("year", eventDateTime.getYear()) // will be removed
View Full Code Here

    */
   public final static String DOT_SNAPSHOT_DIR = ".snapshot";

   public static Instant newInstantFromString(String value) {
     if (value.equalsIgnoreCase(Parameters.DATE_TIME_NOW)) {
       return new Instant();
     }

     return new Instant(DATE_TIME_PARSER.parseMillis(value));
   }
View Full Code Here

   public static Period newPeriodFromString(String value) {
     return PERIOD_FORMATTER.parsePeriod(value);
   }

   public static String printDate(Date date) {
     return DATE_TIME_PRINTER.print(new Instant(date));
   }
View Full Code Here

       fromDate = newDateFromString(fromString);
       Preconditions.checkArgument(
           fromDate.getTime() < toDate.getTime(),
           "Invalid period specified: 'to' must be later than 'from'.");
     } else {
       Instant fromInstant = new Instant(toDate.getTime()).minus(window);
       fromDate = new Date(fromInstant.getMillis());
     }
     return fromDate;
   }
View Full Code Here

            localInstant = iField.set(localInstant, value);
            long result = iZone.convertLocalToUTC(localInstant, false);
            if (get(result) != value) {
                throw new IllegalFieldValueException(iField.getType(), new Integer(value),
                    "Illegal instant due to time zone offset transition: " +
                    DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSS").print(new Instant(localInstant)) +
                    " (" + iZone.getID() + ")");
            }
            return result;
        }
View Full Code Here

     * Get this object as an Instant.
     *
     * @return an Instant using the same millis
     */
    public Instant toInstant() {
        return new Instant(getMillis());
    }
View Full Code Here

        int offset = zone.getOffsetFromLocal(instant);
        instant -= offset;
        if (offset != zone.getOffset(instant)) {
            throw new IllegalArgumentException
                ("Illegal instant due to time zone offset transition: " +
                    DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSS").print(new Instant(instant)));
        }
        return instant;
    }
View Full Code Here

            DateTimeZone zone,
            ReadableInstant gregorianCutover,
            int minDaysInFirstWeek) {
       
        zone = DateTimeUtils.getZone(zone);
        Instant cutoverInstant;
        if (gregorianCutover == null) {
            cutoverInstant = DEFAULT_CUTOVER;
        } else {
            cutoverInstant = gregorianCutover.toInstant();
        }

        GJChronology chrono;

        ArrayList chronos = (ArrayList)cCache.get(zone);
        if (chronos == null) {
            chronos = new ArrayList(2);
            cCache.put(zone, chronos);
        } else {
            for (int i=chronos.size(); --i>=0; ) {
                chrono = (GJChronology)chronos.get(i);
                if (minDaysInFirstWeek == chrono.getMinimumDaysInFirstWeek() &&
                    cutoverInstant.equals(chrono.getGregorianCutover())) {
                   
                    return chrono;
                }
            }
        }
View Full Code Here

    public static GJChronology getInstance(
            DateTimeZone zone,
            long gregorianCutover,
            int minDaysInFirstWeek) {
       
        Instant cutoverInstant;
        if (gregorianCutover == DEFAULT_CUTOVER.getMillis()) {
            cutoverInstant = null;
        } else {
            cutoverInstant = new Instant(gregorianCutover);
        }
        return getInstance(zone, cutoverInstant, minDaysInFirstWeek);
    }
View Full Code Here

TOP

Related Classes of org.joda.time.Instant

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.