Skip to content

Commit

Permalink
Revert "Normalize Date source string when parsing (#609)" (#617)
Browse files Browse the repository at this point in the history
This reverts commit 2eeb817.
  • Loading branch information
xerial authored Jun 27, 2021
1 parent bf5e840 commit 1835f7c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
7 changes: 3 additions & 4 deletions src/main/java/org/sqlite/date/FastDateParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,15 @@ public Object parseObject(final String source) throws ParseException {
* @see org.apache.commons.lang3.time.DateParser#parse(java.lang.String)
*/
public Date parse(final String source) throws ParseException {
String normalizedSource = source.length() == 19 ? (source + ".000") : source;
final Date date= parse(normalizedSource, new ParsePosition(0));
final Date date= parse(source, new ParsePosition(0));
if(date==null) {
// Add a note re supported date range
if (locale.equals(JAPANESE_IMPERIAL)) {
throw new ParseException(
"(The " +locale + " locale does not support dates before 1868 AD)\n" +
"Unparseable date: \""+normalizedSource+"\" does not match "+parsePattern.pattern(), 0);
"Unparseable date: \""+source+"\" does not match "+parsePattern.pattern(), 0);
}
throw new ParseException("Unparseable date: \""+normalizedSource+"\" does not match "+parsePattern.pattern(), 0);
throw new ParseException("Unparseable date: \""+source+"\" does not match "+parsePattern.pattern(), 0);
}
return date;
}
Expand Down
12 changes: 0 additions & 12 deletions src/test/java/org/sqlite/StatementTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -421,18 +421,6 @@ public void dateTimeTest() throws SQLException {
Date d = rs.getDate(1);
assertEquals(day.getTime(), d.getTime());
}

@Test
public void defaultDateTimeTest() throws SQLException {
stat.executeUpdate("create table daywithdefaultdatetime (id integer, datetime datatime default current_timestamp)");
PreparedStatement prep = conn.prepareStatement("insert into daywithdefaultdatetime (id) values (1)");
prep.setInt(1, 1);
prep.executeUpdate();
ResultSet rs = stat.executeQuery("select * from day");
assertTrue(rs.next());
Date d = rs.getDate(2);
assertTrue(d != null);
}

@Test
public void maxRows() throws SQLException {
Expand Down

0 comments on commit 1835f7c

Please sign in to comment.