/** * @return Date value corresponding to the date in the local time zone */ public Date get() { return get(true); }
/** * * @return time in seconds corresponding to this DateWritable */ public long getTimeInSeconds() { return get().getTime() / 1000; }
@Override public String toString() { // For toString, the time does not matter return get(false).toString(); }
static String toES(Object dateWritable) { DateWritable dw = (DateWritable) dateWritable; Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(dw.get().getTime()); return DatatypeConverter.printDate(cal); } }
public IntWritable evaluate(DateWritable d) { if (d == null) { return null; } calendar.setTime(d.get(false)); // Time doesn't matter. result.set(calendar.get(Calendar.DAY_OF_WEEK)); return result; }
public IntWritable evaluate(DateWritable d) { if (d == null) { return null; } calendar.setTime(d.get(false)); // Time doesn't matter. result.set(calendar.get(Calendar.YEAR)); return result; }
public IntWritable evaluate(DateWritable d) { if (d == null) { return null; } calendar.setTime(d.get(false)); // Time doesn't matter. result.set(calendar.get(Calendar.DAY_OF_MONTH)); return result; }
public IntWritable evaluate(DateWritable d) { if (d == null) { return null; } calendar.setTime(d.get(false)); // Time doesn't matter. result.set(calendar.get(Calendar.WEEK_OF_YEAR)); return result; }
public IntWritable evaluate(DateWritable d) { if (d == null) { return null; } calendar.setTime(d.get(false)); // Time doesn't matter. result.set(1 + calendar.get(Calendar.MONTH)); return result; }
private static String normalizeDateCol( Object colValue, String originalColSpec) throws SemanticException { Date value; if (colValue instanceof DateWritable) { value = ((DateWritable) colValue).get(false); // Time doesn't matter. } else if (colValue instanceof Date) { value = (Date) colValue; } else { throw new SemanticException("Unexpected date type " + colValue.getClass()); } return HiveMetaStore.PARTITION_DATE_FORMAT.get().format(value); }
protected Date getDateValue(DeferredObject[] arguments, int i, PrimitiveCategory[] inputTypes, Converter[] converters) throws HiveException { Object obj; if ((obj = arguments[i].get()) == null) { return null; } Date date; switch (inputTypes[i]) { case STRING: case VARCHAR: case CHAR: String dateStr = converters[i].convert(obj).toString(); try { date = DateUtils.getDateFormat().parse(dateStr); } catch (ParseException e) { return null; } break; case TIMESTAMP: case DATE: Object writableValue = converters[i].convert(obj); date = ((DateWritable) writableValue).get(); break; default: throw new UDFArgumentTypeException(0, getFuncName() + " only takes STRING_GROUP and DATE_GROUP types, got " + inputTypes[i]); } return date; }
case DATE: DateWritable dw = (DateWritable) converter.convert(argument.get()); date = dw.get(); break; default:
case DATE: DateWritable dw = (DateWritable) dateWritableConverter.convert(arguments[0].get()); date = dw.get(); break; default:
@Override public Object set(Object o, DateWritable tw) { return create( tw.get()); }
/** * @return Date value corresponding to the date in the local time zone */ public Date get() { return get(true); }
/** * * @return time in seconds corresponding to this DateWritable */ public long getTimeInSeconds() { return get().getTime() / 1000; }
/** * * @return time in seconds corresponding to this DateWritable */ public long getTimeInSeconds() { return get().getTime() / 1000; }
@Override public String toString() { // For toString, the time does not matter return get(false).toString(); }
@Override public Date getMinimum() { if (minimum == null) { return null; } minDate.set(minimum); return minDate.get(); }
public IntWritable evaluate(DateWritable d) { if (d == null) { return null; } calendar.setTime(d.get(false)); // Time doesn't matter. result.set(calendar.get(Calendar.WEEK_OF_YEAR)); return result; }