Zapis daty do MySQL - niepoprawny rok

0

Witam. Staram się zapisać datę do bazy danych.

public void writetoMYSQL(Object[] array) throws SQLException
    {
        String marka = (String) array[0];
        String model = (String) array[1];
        java.sql.Date year = (java.sql.Date) array[2];
        String przebieg = (String) array[3];
        
        prepare = connection.prepareStatement("INSERT into auta values(default,?,?,?,?)");
        
        prepare.setString(1, marka);
        prepare.setString(2, model);
        prepare.setDate(3, year);
        prepare.setString(4, przebieg);
        
        prepare.executeUpdate();
    }

Do metody przekazuje

Object[] ob = {new String("Ford"),
                   new String("Escort"),
                   new java.sql.Date(2000, 10, 5),
                   new String("10000")};
      
      
      db.writetoMYSQL(ob);

Efekt = 3900-11-05

0

Do dokumentacji oczywiście zajrzałeś?

public Date(int year,
int month,
int day)

Deprecated. instead use the constructor Date(long date)
Constructs a Date object initialized with the given year, month, and day.

The result is undefined if a given argument is out of bounds.

Parameters:
year - the year minus 1900; must be 0 to 8099. (Note that 8099 is 9999 minus 1900.)
month - 0 to 11
day - 1 to 31

1 użytkowników online, w tym zalogowanych: 0, gości: 1