Exemple #1
0
  @Override
  public Datum eval(Tuple params) {
    if (params.isBlankOrNull(0) || params.isBlankOrNull(1)) {
      return NullDatum.get();
    }

    String value = params.getText(0);
    String pattern = params.getText(1);

    TimeMeta tm = DateTimeFormat.parseDateTime(value, pattern);

    return new DateDatum(tm);
  }
Exemple #2
0
 public static TimeDatum createTime(Datum datum) {
   switch (datum.type()) {
     case INT8:
       return new TimeDatum(datum.asInt8());
     case CHAR:
     case VARCHAR:
     case TEXT:
       TimeMeta tm = DateTimeFormat.parseDateTime(datum.asChars(), "HH24:MI:SS.MS");
       return new TimeDatum(DateTimeUtil.toTime(tm));
     case TIME:
       return (TimeDatum) datum;
     default:
       throw new TajoRuntimeException(new InvalidValueForCastException(datum.type(), Type.TIME));
   }
 }