Search in sources :

Example 1 with SqlDateValueFactory

use of com.mysql.cj.result.SqlDateValueFactory in project aws-mysql-jdbc by awslabs.

the class ResultSetRegressionTest method testBug23702040.

/**
 * Tests fix for BUG#23702040 - JDBCDATEVALUEFACTORY FAILS TO PARSE SOME DATES.
 *
 * @throws Exception
 */
@Test
public void testBug23702040() throws Exception {
    SimpleDateFormat sdf = TimeUtil.getSimpleDateFormat(null, "yyyy-MM-dd", TimeZone.getTimeZone("Europe/Bucharest"));
    sdf.setLenient(false);
    java.util.Date expected = sdf.parse("1994-03-27");
    Date fromFactory = new SqlDateValueFactory(new DefaultPropertySet(), null, TimeZone.getTimeZone("Europe/Bucharest")).createFromDate(new InternalDate(1994, 3, 27));
    assertEquals(expected.getTime(), fromFactory.getTime());
}
Also used : DefaultPropertySet(com.mysql.cj.conf.DefaultPropertySet) SqlDateValueFactory(com.mysql.cj.result.SqlDateValueFactory) InternalDate(com.mysql.cj.protocol.InternalDate) SimpleDateFormat(java.text.SimpleDateFormat) InternalDate(com.mysql.cj.protocol.InternalDate) LocalDate(java.time.LocalDate) Date(java.sql.Date) Test(org.junit.jupiter.api.Test)

Example 2 with SqlDateValueFactory

use of com.mysql.cj.result.SqlDateValueFactory in project aws-mysql-jdbc by awslabs.

the class ResultSetImpl method getDate.

@Override
public Date getDate(int columnIndex) throws SQLException {
    checkRowPos();
    checkColumnBounds(columnIndex);
    return this.thisRow.getValue(columnIndex - 1, new SqlDateValueFactory(this.session.getPropertySet(), null, this.session.getServerSession().getDefaultTimeZone(), this));
}
Also used : SqlDateValueFactory(com.mysql.cj.result.SqlDateValueFactory)

Example 3 with SqlDateValueFactory

use of com.mysql.cj.result.SqlDateValueFactory in project aws-mysql-jdbc by awslabs.

the class ResultSetImpl method getDate.

@Override
public Date getDate(int columnIndex, Calendar cal) throws SQLException {
    checkRowPos();
    checkColumnBounds(columnIndex);
    return this.thisRow.getValue(columnIndex - 1, new SqlDateValueFactory(this.session.getPropertySet(), cal, cal != null ? cal.getTimeZone() : this.session.getServerSession().getDefaultTimeZone(), this));
}
Also used : SqlDateValueFactory(com.mysql.cj.result.SqlDateValueFactory)

Aggregations

SqlDateValueFactory (com.mysql.cj.result.SqlDateValueFactory)3 DefaultPropertySet (com.mysql.cj.conf.DefaultPropertySet)1 InternalDate (com.mysql.cj.protocol.InternalDate)1 Date (java.sql.Date)1 SimpleDateFormat (java.text.SimpleDateFormat)1 LocalDate (java.time.LocalDate)1 Test (org.junit.jupiter.api.Test)1