Package com.impossibl.postgres.datetime.instants

Examples of com.impossibl.postgres.datetime.instants.Instant


    else if (val instanceof Date) {
      return (Date) val;
    }
    else if (val instanceof Instant) {

      Instant inst = (Instant) val;

      if (inst.getType() != Instant.Type.Time) {

        return inst.switchTo(zone).toDate();

      }
    }

    throw createCoercionException(val.getClass(), Date.class);
View Full Code Here


    else if (val instanceof Time) {
      return (Time) val;
    }
    else if (val instanceof Instant) {

      Instant inst = (Instant) val;

      if (inst.getType() != Instant.Type.Date && inst.getType() != Instant.Type.Infinity) {

        return ((Instant) val).switchTo(zone).toTime();

      }
View Full Code Here

        buffer.writeInt(-1);
      }
      else {

        Instant inst = (Instant) val;

        long micros = inst.getMicrosLocal() % DAYS.toMicros(1);

        buffer.writeInt(8);
        buffer.writeLong(micros);
      }
View Full Code Here

        buffer.writeInt(-1);
      }
      else {

        Instant inst = (Instant) val;

        long micros = inst.getMicrosLocal() % DAYS.toMicros(1);

        int tzOffsetSecs = (int) -inst.getZoneOffsetSecs();

        buffer.writeInt(12);
        buffer.writeLong(micros);
        buffer.writeInt(tzOffsetSecs);
      }
View Full Code Here

        buffer.writeInt(-1);
      }
      else {

        Instant inst = (Instant) val;

        long micros;
        if (primitiveType == PrimitiveType.TimestampTZ) {
          micros = inst.getMicrosUTC();
        }
        else {
          micros = inst.disambiguate(TimeZone.getDefault()).getMicrosLocal();
        }

        if (!isInfinity(micros)) {

          micros -= PG_JAVA_EPOCH_DIFF_MICROS;
View Full Code Here

      Map<String, Object> pieces = new HashMap<>();

      context.getTimestampFormatter().getParser().parse(buffer.toString(), 0, pieces);

      Instant instant = Instants.timestampFromPieces(pieces, context.getTimeZone());

      if (primitiveType != PrimitiveType.TimestampTZ) {
        instant = instant.ambiguate();
      }

      return instant;
    }
View Full Code Here

        buffer.writeInt(-1);
      }
      else {

        Instant inst = (Instant) val;

        int daysPg;

        if (inst.getType() == Instant.Type.Infinity) {
          daysPg = inst.getMicrosLocal() < 0 ? Integer.MIN_VALUE : Integer.MAX_VALUE;
        }
        else {
          daysPg = toPgDays(inst);
        }
View Full Code Here

TOP

Related Classes of com.impossibl.postgres.datetime.instants.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.