[New] Now all date parsing and formatting is done using ISO8601
This commit is contained in:
parent
80a7a326e0
commit
98e7490164
|
@ -26,6 +26,8 @@ import li.strolch.model.Locator.LocatorBuilder;
|
|||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import ch.eitchnet.utils.iso8601.ISO8601FormatFactory;
|
||||
|
||||
/**
|
||||
* The Order is an object used in the EDF to transfer data from one range to another. Orders are not to be thought of as
|
||||
* Resources. Resources are supposed to be thought of as things i.e. a table, a machine and so forth, where a order is
|
||||
|
@ -92,11 +94,10 @@ public class Order extends GroupedParameterizedElement {
|
|||
String date = element.getAttribute(Tags.DATE);
|
||||
String state = element.getAttribute(Tags.STATE);
|
||||
|
||||
// TODO the format should be globally configured
|
||||
if (date == null || date.isEmpty()) {
|
||||
setDate(0);
|
||||
} else {
|
||||
setDate(Long.parseLong(date));
|
||||
setDate(ISO8601FormatFactory.getInstance().getDateFormat().parse(date));
|
||||
}
|
||||
|
||||
if (state == null || state.isEmpty()) {
|
||||
|
@ -142,8 +143,7 @@ public class Order extends GroupedParameterizedElement {
|
|||
Element orderElement = doc.createElement(Tags.ORDER);
|
||||
fillElement(orderElement);
|
||||
|
||||
// TODO the format should be globally configured
|
||||
orderElement.setAttribute(Tags.DATE, Long.toString(this.date));
|
||||
orderElement.setAttribute(Tags.DATE, ISO8601FormatFactory.getInstance().formatDate(this.date));
|
||||
orderElement.setAttribute(Tags.STATE, this.state.toString());
|
||||
|
||||
return orderElement;
|
||||
|
@ -187,9 +187,8 @@ public class Order extends GroupedParameterizedElement {
|
|||
builder.append(this.type);
|
||||
builder.append(", state=");
|
||||
builder.append(this.state);
|
||||
// TODO the format should be globally configured
|
||||
builder.append(", date=");
|
||||
builder.append(this.date);
|
||||
builder.append(ISO8601FormatFactory.getInstance().formatDate(this.date));
|
||||
builder.append("]");
|
||||
|
||||
return builder.toString();
|
||||
|
|
|
@ -38,6 +38,7 @@ import li.strolch.model.parameter.FloatParameter;
|
|||
import li.strolch.model.parameter.IntegerParameter;
|
||||
import li.strolch.model.parameter.LongParameter;
|
||||
import li.strolch.model.parameter.Parameter;
|
||||
import li.strolch.model.parameter.StringListParameter;
|
||||
import li.strolch.model.parameter.StringParameter;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
@ -239,6 +240,9 @@ public abstract class ParameterizedElement extends AbstractStrolchElement {
|
|||
} else if (paramtype.equals(BooleanParameter.TYPE)) {
|
||||
BooleanParameter param = new BooleanParameter(paramElement);
|
||||
addParameter(param);
|
||||
} else if (paramtype.equals(StringListParameter.TYPE)) {
|
||||
StringListParameter param = new StringListParameter(paramElement);
|
||||
addParameter(param);
|
||||
} else {
|
||||
String msg = "What kind of parameter is this: {0}"; //$NON-NLS-1$
|
||||
msg = MessageFormat.format(msg, paramtype);
|
||||
|
|
|
@ -44,9 +44,9 @@ public abstract class AbstractParameter<T> extends AbstractStrolchElement implem
|
|||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
protected boolean hidden;
|
||||
protected String interpretation;
|
||||
protected String uom;
|
||||
protected boolean hidden = false;
|
||||
protected String interpretation = INTERPRETATION_NONE;
|
||||
protected String uom = UOM_NONE;
|
||||
|
||||
protected ParameterizedElement parent;
|
||||
|
||||
|
@ -149,18 +149,18 @@ public abstract class AbstractParameter<T> extends AbstractStrolchElement implem
|
|||
}
|
||||
|
||||
String interpretation = element.getAttribute(Tags.INTERPRETATION);
|
||||
String isHidden = element.getAttribute(Tags.HIDDEN);
|
||||
String hidden = element.getAttribute(Tags.HIDDEN);
|
||||
String uom = element.getAttribute(Tags.UOM);
|
||||
|
||||
setInterpretation(interpretation);
|
||||
setUom(uom);
|
||||
|
||||
if (isHidden == null) {
|
||||
if (StringHelper.isEmpty(hidden)) {
|
||||
setHidden(false);
|
||||
} else {
|
||||
if (isHidden.equalsIgnoreCase(Boolean.TRUE.toString())) {
|
||||
if (hidden.equalsIgnoreCase(Boolean.TRUE.toString())) {
|
||||
setHidden(true);
|
||||
} else if (isHidden.equalsIgnoreCase(Boolean.FALSE.toString())) {
|
||||
} else if (hidden.equalsIgnoreCase(Boolean.FALSE.toString())) {
|
||||
setHidden(false);
|
||||
} else {
|
||||
String msg = "Boolean string must be either {0} or {1}"; //$NON-NLS-1$
|
||||
|
|
|
@ -21,14 +21,15 @@
|
|||
*/
|
||||
package li.strolch.model.parameter;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import li.strolch.exception.StrolchException;
|
||||
import li.strolch.model.Tags;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import ch.eitchnet.utils.helper.StringHelper;
|
||||
import ch.eitchnet.utils.iso8601.ISO8601FormatFactory;
|
||||
|
||||
/**
|
||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||
|
@ -73,14 +74,12 @@ public class DateParameter extends AbstractParameter<Long> {
|
|||
throw new StrolchException(msg);
|
||||
}
|
||||
|
||||
setValue(Long.valueOf(valueS));
|
||||
setValue(ISO8601FormatFactory.getInstance().getDateFormat().parse(valueS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValueAsString() {
|
||||
// TODO the format should be globally configured
|
||||
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
return dateFormat.format(this.value);
|
||||
return ISO8601FormatFactory.getInstance().formatDate(this.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -71,9 +71,9 @@ public interface Parameter<T> extends StrolchElement {
|
|||
/**
|
||||
* the value of the parameter
|
||||
*
|
||||
* @param obj
|
||||
* @param value
|
||||
*/
|
||||
public void setValue(T obj);
|
||||
public void setValue(T value);
|
||||
|
||||
/**
|
||||
* get the hidden attribute
|
||||
|
|
Loading…
Reference in New Issue