当前位置: 首页>>代码示例>>Java>>正文


Java DateTimeUtils.MILLIS_PER_DAY属性代码示例

本文整理汇总了Java中org.apache.calcite.avatica.util.DateTimeUtils.MILLIS_PER_DAY属性的典型用法代码示例。如果您正苦于以下问题:Java DateTimeUtils.MILLIS_PER_DAY属性的具体用法?Java DateTimeUtils.MILLIS_PER_DAY怎么用?Java DateTimeUtils.MILLIS_PER_DAY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.calcite.avatica.util.DateTimeUtils的用法示例。


在下文中一共展示了DateTimeUtils.MILLIS_PER_DAY属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convert

private static Object convert(Object o, Class clazz) {
  if (o == null) {
    return null;
  }
  Primitive primitive = Primitive.of(clazz);
  if (primitive != null) {
    clazz = primitive.boxClass;
  } else {
    primitive = Primitive.ofBox(clazz);
  }
  if (clazz.isInstance(o)) {
    return o;
  }
  if (o instanceof Date && primitive != null) {
    o = ((Date) o).getTime() / DateTimeUtils.MILLIS_PER_DAY;
  }
  if (o instanceof Number && primitive != null) {
    return primitive.number((Number) o);
  }
  return o;
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:Elasticsearch2Enumerator.java

示例2: getMillisSinceEpoch

/** Returns the number of milliseconds since the epoch. */
public long getMillisSinceEpoch() {
  final int year = Integer.valueOf(v.substring(0, 4));
  final int month = Integer.valueOf(v.substring(5, 7));
  final int day = Integer.valueOf(v.substring(8, 10));
  final int h = Integer.valueOf(v.substring(11, 13));
  final int m = Integer.valueOf(v.substring(14, 16));
  final int s = Integer.valueOf(v.substring(17, 19));
  final int ms = getMillisInSecond();
  final int d = DateTimeUtils.ymdToUnixDate(year, month, day);
  return d * DateTimeUtils.MILLIS_PER_DAY
      + h * DateTimeUtils.MILLIS_PER_HOUR
      + m * DateTimeUtils.MILLIS_PER_MINUTE
      + s * DateTimeUtils.MILLIS_PER_SECOND
      + ms;
}
 
开发者ID:apache,项目名称:calcite,代码行数:16,代码来源:TimestampString.java

示例3: shift

private static Time shift(Time v) {
    if (v == null) {
        return null;
    }
    long time = v.getTime();
    int offset = TimeZone.getDefault().getOffset(time);
    return new Time((time + offset) % DateTimeUtils.MILLIS_PER_DAY);
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:8,代码来源:JdbcUtils.java

示例4: shift

private static Time shift(Time v) {
  if (v == null) {
    return null;
  }
  long time = v.getTime();
  int offset = TimeZone.getDefault().getOffset(time);
  return new Time((time + offset) % DateTimeUtils.MILLIS_PER_DAY);
}
 
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:JdbcUtils.java

示例5: currentTime

/** SQL {@code CURRENT_TIME} function. */
@NonDeterministic
public static int currentTime(DataContext root) {
  int time = (int) (currentTimestamp(root) % DateTimeUtils.MILLIS_PER_DAY);
  if (time < 0) {
    time += DateTimeUtils.MILLIS_PER_DAY;
  }
  return time;
}
 
开发者ID:apache,项目名称:calcite,代码行数:9,代码来源:SqlFunctions.java

示例6: currentDate

/** SQL {@code CURRENT_DATE} function. */
@NonDeterministic
public static int currentDate(DataContext root) {
  final long timestamp = currentTimestamp(root);
  int date = (int) (timestamp / DateTimeUtils.MILLIS_PER_DAY);
  final int time = (int) (timestamp % DateTimeUtils.MILLIS_PER_DAY);
  if (time < 0) {
    --date;
  }
  return date;
}
 
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:SqlFunctions.java

示例7: addMonths

/** Adds a given number of months to a timestamp, represented as the number
 * of milliseconds since the epoch. */
public static long addMonths(long timestamp, int m) {
  final long millis =
      DateTimeUtils.floorMod(timestamp, DateTimeUtils.MILLIS_PER_DAY);
  timestamp -= millis;
  final long x =
      addMonths((int) (timestamp / DateTimeUtils.MILLIS_PER_DAY), m);
  return x * DateTimeUtils.MILLIS_PER_DAY + millis;
}
 
开发者ID:apache,项目名称:calcite,代码行数:10,代码来源:SqlFunctions.java

示例8: getValue

private static Object getValue(ResultSet resultSet, int type, int j,
    Calendar calendar) throws SQLException {
  switch (type) {
  case Types.BIGINT:
    final long aLong = resultSet.getLong(j + 1);
    return aLong == 0 && resultSet.wasNull() ? null : aLong;
  case Types.INTEGER:
    final int anInt = resultSet.getInt(j + 1);
    return anInt == 0 && resultSet.wasNull() ? null : anInt;
  case Types.SMALLINT:
    final short aShort = resultSet.getShort(j + 1);
    return aShort == 0 && resultSet.wasNull() ? null : aShort;
  case Types.TINYINT:
    final byte aByte = resultSet.getByte(j + 1);
    return aByte == 0 && resultSet.wasNull() ? null : aByte;
  case Types.DOUBLE:
  case Types.FLOAT:
    final double aDouble = resultSet.getDouble(j + 1);
    return aDouble == 0D && resultSet.wasNull() ? null : aDouble;
  case Types.REAL:
    final float aFloat = resultSet.getFloat(j + 1);
    return aFloat == 0D && resultSet.wasNull() ? null : aFloat;
  case Types.DATE:
    final Date aDate = resultSet.getDate(j + 1, calendar);
    return aDate == null
        ? null
        : (int) (aDate.getTime() / DateTimeUtils.MILLIS_PER_DAY);
  case Types.TIME:
    final Time aTime = resultSet.getTime(j + 1, calendar);
    return aTime == null
        ? null
        : (int) (aTime.getTime() % DateTimeUtils.MILLIS_PER_DAY);
  case Types.TIMESTAMP:
    final Timestamp aTimestamp = resultSet.getTimestamp(j + 1, calendar);
    return aTimestamp == null ? null : aTimestamp.getTime();
  case Types.ARRAY:
    final Array array = resultSet.getArray(j + 1);
    if (null == array) {
      return null;
    }
    try {
      // Recursively extracts an Array using its ResultSet-representation
      return extractUsingResultSet(array, calendar);
    } catch (UnsupportedOperationException | SQLFeatureNotSupportedException e) {
      // Not every database might implement Array.getResultSet(). This call
      // assumes a non-nested array (depends on the db if that's a valid assumption)
      return extractUsingArray(array, calendar);
    }
  case Types.STRUCT:
    Struct struct = resultSet.getObject(j + 1, Struct.class);
    Object[] attrs = struct.getAttributes();
    List<Object> list = new ArrayList<>(attrs.length);
    for (Object o : attrs) {
      list.add(o);
    }
    return list;
  default:
    return resultSet.getObject(j + 1);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:60,代码来源:JdbcResultSet.java

示例9: getValue

private static Object getValue(ResultSet resultSet, int type, int j,
                               Calendar calendar) throws SQLException {
  switch (type) {
    case Types.BIGINT:
      final long aLong = resultSet.getLong(j + 1);
      return aLong == 0 && resultSet.wasNull() ? null : aLong;
    case Types.INTEGER:
      final int anInt = resultSet.getInt(j + 1);
      return anInt == 0 && resultSet.wasNull() ? null : anInt;
    case Types.SMALLINT:
      final short aShort = resultSet.getShort(j + 1);
      return aShort == 0 && resultSet.wasNull() ? null : aShort;
    case Types.TINYINT:
      final byte aByte = resultSet.getByte(j + 1);
      return aByte == 0 && resultSet.wasNull() ? null : aByte;
    case Types.DOUBLE:
    case Types.FLOAT:
      final double aDouble = resultSet.getDouble(j + 1);
      return aDouble == 0D && resultSet.wasNull() ? null : aDouble;
    case Types.REAL:
      final float aFloat = resultSet.getFloat(j + 1);
      return aFloat == 0D && resultSet.wasNull() ? null : aFloat;
    case Types.DATE:
      final Date aDate = resultSet.getDate(j + 1, calendar);
      return aDate == null
          ? null
          : (int) (aDate.getTime() / DateTimeUtils.MILLIS_PER_DAY);
    case Types.TIME:
      final Time aTime = resultSet.getTime(j + 1, calendar);
      return aTime == null
          ? null
          : (int) (aTime.getTime() % DateTimeUtils.MILLIS_PER_DAY);
    case Types.TIMESTAMP:
      final Timestamp aTimestamp = resultSet.getTimestamp(j + 1, calendar);
      return aTimestamp == null ? null : aTimestamp.getTime();
    case Types.ARRAY:
      final Array array = resultSet.getArray(j + 1);
      if (null == array) {
        return null;
      }
      ResultSet arrayValues = array.getResultSet();
      TreeMap<Integer, Object> map = new TreeMap<>();
      while (arrayValues.next()) {
        // column 1 is the index in the array, column 2 is the value.
        // Recurse on `getValue` to unwrap nested types correctly.
        // `j` is zero-indexed and incremented for us, thus we have `1` being used twice.
        map.put(arrayValues.getInt(1), getValue(arrayValues, array.getBaseType(), 1, calendar));
      }
      // If the result set is not in the same order as the actual Array, TreeMap fixes that.
      // Need to make a concrete list to ensure Jackson serialization.
      //return new ListLike<Object>(new ArrayList<>(map.values()), ListLikeType.ARRAY);
      return new ArrayList<>(map.values());
    case Types.STRUCT:
      Struct struct = resultSet.getObject(j + 1, Struct.class);
      Object[] attrs = struct.getAttributes();
      List<Object> list = new ArrayList<>(attrs.length);
      for (Object o : attrs) {
        list.add(o);
      }
      return list;
    default:
      return resultSet.getObject(j + 1);
  }
}
 
开发者ID:qubole,项目名称:quark,代码行数:64,代码来源:QuarkMetaResultSet.java

示例10: apply

public Integer apply(Time a0) {
  return a0 == null
      ? null
      : (int) (a0.getTime() % DateTimeUtils.MILLIS_PER_DAY);
}
 
开发者ID:apache,项目名称:calcite,代码行数:5,代码来源:ColumnLoader.java

示例11: toInt

public static int toInt(java.util.Date v, TimeZone timeZone) {
  return (int) (toLong(v, timeZone)  / DateTimeUtils.MILLIS_PER_DAY);
}
 
开发者ID:apache,项目名称:calcite,代码行数:3,代码来源:SqlFunctions.java

示例12: internalToDate

/** Converts the internal representation of a SQL DATE (int) to the Java
 * type used for UDF parameters ({@link java.sql.Date}). */
public static java.sql.Date internalToDate(int v) {
  final long t = v * DateTimeUtils.MILLIS_PER_DAY;
  return new java.sql.Date(t - LOCAL_TZ.getOffset(t));
}
 
开发者ID:apache,项目名称:calcite,代码行数:6,代码来源:SqlFunctions.java

示例13: localTime

/** SQL {@code LOCAL_TIME} function. */
@NonDeterministic
public static int localTime(DataContext root) {
  return (int) (localTimestamp(root) % DateTimeUtils.MILLIS_PER_DAY);
}
 
开发者ID:apache,项目名称:calcite,代码行数:5,代码来源:SqlFunctions.java

示例14: getMillisSinceEpoch

/** Returns the number of milliseconds since the epoch. Always a multiple of
 * 86,400,000 (the number of milliseconds in a day). */
public long getMillisSinceEpoch() {
  return getDaysSinceEpoch() * DateTimeUtils.MILLIS_PER_DAY;
}
 
开发者ID:apache,项目名称:calcite,代码行数:5,代码来源:DateString.java

示例15: d2ts

/** Converts a date (days since epoch) and milliseconds (since midnight)
 * into a timestamp (milliseconds since epoch). */
private long d2ts(int date, int millis) {
  return date * DateTimeUtils.MILLIS_PER_DAY + millis;
}
 
开发者ID:apache,项目名称:calcite,代码行数:5,代码来源:SqlFunctionsTest.java


注:本文中的org.apache.calcite.avatica.util.DateTimeUtils.MILLIS_PER_DAY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。