org.apache.kylin.common.util.DateFormat.formatToTimeWithoutMilliStr()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(195)

本文整理了Java中org.apache.kylin.common.util.DateFormat.formatToTimeWithoutMilliStr()方法的一些代码示例,展示了DateFormat.formatToTimeWithoutMilliStr()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateFormat.formatToTimeWithoutMilliStr()方法的具体详情如下:
包路径:org.apache.kylin.common.util.DateFormat
类名称:DateFormat
方法名:formatToTimeWithoutMilliStr

DateFormat.formatToTimeWithoutMilliStr介绍

暂无

代码示例

代码示例来源:origin: apache/kylin

/**
 *
 * @param id
 * @return return like "0000001430812800000"
 */
@Override
protected String getValueFromIdImpl(int id) {
  if (id == nullId())
    return null;
  long millis = 1000L * id;
  return DateFormat.formatToTimeWithoutMilliStr(millis);
}

代码示例来源:origin: apache/kylin

public void encodeDecode(String origin) {
  long a = encode(origin);
  String back = decode(a);
  String originChoppingMilis = DateFormat.formatToTimeWithoutMilliStr(DateFormat.stringToMillis(origin));
  String backMillis = DateFormat.formatToTimeWithoutMilliStr(Long.parseLong(back));
  Assert.assertEquals(originChoppingMilis, backMillis);
}

代码示例来源:origin: apache/kylin

case 1:
  normalized = TimeUtil.getMinuteStart(t);
  result.add(DateFormat.formatToTimeWithoutMilliStr(normalized));
  break;
case 2:
  normalized = TimeUtil.getHourStart(t);
  result.add(DateFormat.formatToTimeWithoutMilliStr(normalized));
  break;
case 3:

代码示例来源:origin: apache/kylin

private String tsRangeToStr(long ts, PartitionDesc part) {
  String value;
  DataType partitionColType = part.getPartitionDateColumnRef().getType();
  if (partitionColType.isDate()) {
    value = DateFormat.formatToDateStr(ts);
  } else if (partitionColType.isTimeFamily()) {
    value = DateFormat.formatToTimeWithoutMilliStr(ts);
  } else if (partitionColType.isStringFamily() || partitionColType.isIntegerFamily()) {//integer like 20160101
    String partitionDateFormat = part.getPartitionDateFormat();
    if (StringUtils.isEmpty(partitionDateFormat)) {
      value = "" + ts;
    } else {
      value = DateFormat.formatToDateStr(ts, partitionDateFormat);
    }
  } else {
    throw new RuntimeException("Type " + partitionColType + " is not valid partition column type");
  }
  return value;
}

代码示例来源:origin: apache/kylin

private ByteArray encodeTime(long ts, int index, int roundingFlag) {
    String value;
    DataType partitionColType = info.getColumnType(index);
    if (partitionColType.isDate()) {
      value = DateFormat.formatToDateStr(ts);
    } else if (partitionColType.isTimeFamily()) {
      value = DateFormat.formatToTimeWithoutMilliStr(ts);
    } else if (partitionColType.isStringFamily() || partitionColType.isIntegerFamily()) {//integer like 20160101
      String partitionDateFormat = segment.getModel().getPartitionDesc().getPartitionDateFormat();
      if (StringUtils.isEmpty(partitionDateFormat)) {
        value = "" + ts;
      } else {
        value = DateFormat.formatToDateStr(ts, partitionDateFormat);
      }
    } else {
      throw new RuntimeException("Type " + partitionColType + " is not valid partition column type");
    }

    ByteBuffer buffer = ByteBuffer.allocate(info.getMaxColumnLength());
    info.getCodeSystem().encodeColumnValue(index, value, roundingFlag, buffer);

    return ByteArray.copyOf(buffer.array(), 0, buffer.position());
  }
}

代码示例来源:origin: apache/kylin

public void encodeDecode(String origin) {
  int a = dict.getIdFromValue(origin);
  String back = dict.getValueFromId(a);
  String originChoppingMilis = DateFormat.formatToTimeWithoutMilliStr(DateFormat.stringToMillis(origin));
  Assert.assertEquals(originChoppingMilis, back);
}

代码示例来源:origin: org.apache.kylin/kylin-core-dictionary

/**
 *
 * @param id
 * @return return like "0000001430812800000"
 */
@Override
protected String getValueFromIdImpl(int id) {
  if (id == nullId())
    return null;
  long millis = 1000L * id;
  return DateFormat.formatToTimeWithoutMilliStr(millis);
}

代码示例来源:origin: org.apache.kylin/kylin-source-kafka

case 1:
  normalized = TimeUtil.getMinuteStart(t);
  result.add(DateFormat.formatToTimeWithoutMilliStr(normalized));
  break;
case 2:
  normalized = TimeUtil.getHourStart(t);
  result.add(DateFormat.formatToTimeWithoutMilliStr(normalized));
  break;
case 3:

代码示例来源:origin: org.apache.kylin/kylin-core-cube

private String tsRangeToStr(long ts, PartitionDesc part) {
  String value;
  DataType partitionColType = part.getPartitionDateColumnRef().getType();
  if (partitionColType.isDate()) {
    value = DateFormat.formatToDateStr(ts);
  } else if (partitionColType.isTimeFamily()) {
    value = DateFormat.formatToTimeWithoutMilliStr(ts);
  } else if (partitionColType.isStringFamily() || partitionColType.isIntegerFamily()) {//integer like 20160101
    String partitionDateFormat = part.getPartitionDateFormat();
    if (StringUtils.isEmpty(partitionDateFormat)) {
      value = "" + ts;
    } else {
      value = DateFormat.formatToDateStr(ts, partitionDateFormat);
    }
  } else {
    throw new RuntimeException("Type " + partitionColType + " is not valid partition column type");
  }
  return value;
}

代码示例来源:origin: org.apache.kylin/kylin-core-cube

private ByteArray encodeTime(long ts, int index, int roundingFlag) {
    String value;
    DataType partitionColType = info.getColumnType(index);
    if (partitionColType.isDate()) {
      value = DateFormat.formatToDateStr(ts);
    } else if (partitionColType.isTimeFamily()) {
      value = DateFormat.formatToTimeWithoutMilliStr(ts);
    } else if (partitionColType.isStringFamily() || partitionColType.isIntegerFamily()) {//integer like 20160101
      String partitionDateFormat = segment.getModel().getPartitionDesc().getPartitionDateFormat();
      if (StringUtils.isEmpty(partitionDateFormat)) {
        value = "" + ts;
      } else {
        value = DateFormat.formatToDateStr(ts, partitionDateFormat);
      }
    } else {
      throw new RuntimeException("Type " + partitionColType + " is not valid partition column type");
    }

    ByteBuffer buffer = ByteBuffer.allocate(info.getMaxColumnLength());
    info.getCodeSystem().encodeColumnValue(index, value, roundingFlag, buffer);

    return ByteArray.copyOf(buffer.array(), 0, buffer.position());
  }
}

相关文章