fix #1386
This commit is contained in:
parent
eeb8ade5c0
commit
81043e58e2
@ -38,9 +38,10 @@ import java.io.InputStream;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.time.Instant;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
@ -193,6 +194,10 @@ public class ParsingUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static public LocalDateTime stringToLocalDate(String s) {
|
static public LocalDateTime stringToLocalDate(String s) {
|
||||||
return LocalDateTime.parse(s, DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
if (s.endsWith("Z")) { // UTC time
|
||||||
|
Instant instant = Instant.parse(s);
|
||||||
|
return LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
|
||||||
|
} else
|
||||||
|
return LocalDateTime.parse(s, DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,4 +107,25 @@ public class ParsingUtilitiesTests extends RefineTest {
|
|||||||
Assert.assertEquals(zdtString, historyEntryDate);
|
Assert.assertEquals(zdtString, historyEntryDate);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void parseProjectModifiedBeforeJDK8() {
|
||||||
|
String modified = "2014-01-15T21:46:25Z";
|
||||||
|
Assert.assertNotEquals(ParsingUtilities.stringToLocalDate(modified).toString(),
|
||||||
|
modified);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void strSubstitutorTest() {
|
||||||
|
Map<String, String> data = new HashMap<String, String>(6);
|
||||||
|
|
||||||
|
data.put("value", "1234");
|
||||||
|
data.put("field_format", "String");
|
||||||
|
|
||||||
|
StrSubstitutor sub = new StrSubstitutor(data);
|
||||||
|
String message = "The value ${value} in row ${row_number} and column ${column_number} is not type ${field_type} and format ${field_format}";
|
||||||
|
String result = sub.replace(message);
|
||||||
|
System.out.println("XXXXXXXX:" + result);
|
||||||
|
Assert.assertTrue(result.contains("1234"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user