0
我嘗試從SQLite數據庫檢索數據時出現錯誤。來自SQLite的Java數據解析錯誤
它檢索數據的第一行到表,但是當該日期是有它給出以下所示的錯誤。
這是我得到錯誤的代碼。
try {
con = DriverManager.getConnection("jdbc:sqlite:Rooms.db");
con.setAutoCommit(false);
pst = con.prepareStatement("Select * from Standard");
rs = pst.executeQuery();
while (rs.next())
{
LocalDate sD = null;
LocalDate eD = null;
if (rs.getDate(6) != null)
{
sD = Conv(rs.getDate(6));
eD = Conv(rs.getDate(7));
System.out.println(sD + " " + eD);
if (chkIn.getValue().isBefore(sD) == true && chkOut.getValue().isBefore(eD) == true)
{
datas.add(new StandardRoomList(rs.getString(1), rs.getString(2) , "£" + (rs.getInt(3)*pri), "" + rs.getInt(4)));
}
}
這是我收到的錯誤:
Caused by: java.text.ParseException: Unparseable date: "2017-11-17" does not match (\p{Nd}++)\Q-\E(\p{Nd}++)\Q-\E(\p{Nd}++)\Q \E(\p{Nd}++)\Q:\E(\p{Nd}++)\Q:\E(\p{Nd}++)\Q.\E(\p{Nd}++)
at org.sqlite.date.FastDateParser.parse(FastDateParser.java:299)
at org.sqlite.date.FastDateFormat.parse(FastDateFormat.java:490)
at org.sqlite.jdbc3.JDBC3ResultSet.getDate(JDBC3ResultSet.java:293)
... 64 more