Commit 3f6f05f2 authored by rwm's avatar rwm

fixed illegal output of DateTimeAccuracy

parent dad1fe5b
......@@ -150,8 +150,11 @@ public class DateTimeAccuracy implements Temporal, Comparable<DateTimeAccuracy>
*/
private void appendWithZeroPrefix(StringBuilder builder, TemporalField field, int digits){
int v = dateTime.get(field);
for(int i=digits; i>1 && v<(10^(i-1)); i--){
int pow = 1;
for( int i=1; i<digits; i++ )pow *= 10;
while( v < pow && pow > 1 ){
builder.append('0');
pow /= 10;
}
builder.append(v);
}
......
......@@ -41,11 +41,14 @@ public class TestDateTimeAccuracy {
}
@Test
public void testParseToString(){
final String str = "2001-03-04T05:06:07";
DateTimeAccuracy a = DateTimeAccuracy.parsePartialIso8601(str);
final String[] str = new String[]{"2001-03-04T10:16:07", "2001-03-04T10:16:00"};
DateTimeAccuracy a = DateTimeAccuracy.parsePartialIso8601(str[0]);
Assert.assertEquals(ChronoUnit.SECONDS, a.getAccuracy());
assertFieldValues(a, new int[]{2001,3,4,5,6,7});
Assert.assertEquals(str, a.toPartialIso8601());
assertFieldValues(a, new int[]{2001,3,4,10,16,7});
for( String s : str ){
a = DateTimeAccuracy.parsePartialIso8601(s);
Assert.assertEquals(s, a.toPartialIso8601());
}
}
@Test
......
......@@ -33,7 +33,7 @@ public class XPathEvaluatorTest {
Observation o = s.get();
//System.out.println("XXX:"+eval.evaluateToString("translate(fact/@start,'-:T','')", o));
//System.out.println(XPathEvaluator.toXMLString(o));
String[] trueExpressions = new String[]{"f:fact/@patient", "f:fact/@concept", "f:fact/@start", "number(translate(f:fact/@start,'-:T',''))=201409070104003"};
String[] trueExpressions = new String[]{"f:fact/@patient", "f:fact/@concept", "f:fact/@start", "number(translate(f:fact/@start,'-:T',''))=20140907104003"};
for( String expr : trueExpressions ){
Assert.assertEquals(expr, true, eval.test(expr, o));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment