public static String getNumericValueString(InstancesHeader context, int attIndex, double value) { if (context != null) { int instAttIndex = attIndex < context.classIndex() ? attIndex : attIndex + 1; if (instAttIndex < context.numAttributes()) { if (context.attribute(instAttIndex).isDate()) { return context.attribute(instAttIndex).formatDate(value); } } } return Double.toString(value); }
public static String getNumericValueString(InstancesHeader context, int attIndex, double value) { if (context != null) { int instAttIndex = attIndex < context.classIndex() ? attIndex : attIndex + 1; if (instAttIndex < context.numAttributes()) { if (context.attribute(instAttIndex).isDate()) { return context.attribute(instAttIndex).formatDate(value); } } } return Double.toString(value); }
/** * Text representation of a InstanceImpl. */ @Override public String toString() { StringBuilder str = new StringBuilder(); for (int attIndex = 0; attIndex < this.numAttributes(); attIndex++) { if (!this.isMissing(attIndex)) { if (this.attribute(attIndex).isNominal()) { int valueIndex = (int) this.value(attIndex); String stringValue = this.attribute(attIndex).value(valueIndex); str.append(stringValue).append(","); } else if (this.attribute(attIndex).isNumeric()) { str.append(this.value(attIndex)).append(","); } else if (this.attribute(attIndex).isDate()) { SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); str.append(dateFormatter.format(this.value(attIndex))).append(","); } } else { str.append("?,"); } } return str.toString(); }