Binders { public static Binder dateBinder() { return DATE_BINDER; } private  Binders(); static Binder defaultBinder(); static Binder stringBinder(); static Binder dateBinder(); static Binder timestampBinder(); static Binder timeBinder(); static Binder decimalBinder(); static Binder integerBinder();  }
@Test public void dateBinderBindsSqlDate() throws SQLException { Date date = Date.valueOf("1975-07-19"); Binder binder = Binders.dateBinder(); binder.bind(stmt, 1, date); verify(stmt).setDate(1, date); }
@Test public void dateBinderBindsUtilDate() throws SQLException { java.util.Date date = new java.util.Date(Date.valueOf("1975-07-19").getTime()); Binder binder = Binders.dateBinder(); binder.bind(stmt, 1, date); verify(stmt).setDate(1, Date.valueOf("1975-07-19")); }
@Test public void dateBinderBindsCalendar() throws SQLException { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(Date.valueOf("1975-07-19").getTime()); Binder binder = Binders.dateBinder(); binder.bind(stmt, 1, calendar); verify(stmt).setDate(1, Date.valueOf("1975-07-19"), calendar); }
@Test public void dateBinderBindsString() throws SQLException { Binder binder = Binders.dateBinder(); binder.bind(stmt, 1, "1975-07-19"); verify(stmt).setDate(1, Date.valueOf("1975-07-19")); }
@Test public void dateBinderBindsLocalDate() throws SQLException { Binder binder = Binders.dateBinder(); binder.bind(stmt, 1, LocalDate.parse("1975-07-19")); verify(stmt).setDate(1, Date.valueOf("1975-07-19")); }
@Test public void dateBinderBindsLocalDateTime() throws SQLException { Binder binder = Binders.dateBinder(); binder.bind(stmt, 1, LocalDateTime.parse("1975-07-19T01:02:03.000")); verify(stmt).setDate(1, Date.valueOf("1975-07-19")); }
@Test public void dateBinderBindsInstant() throws SQLException { Binder binder = Binders.dateBinder(); Instant value = LocalDateTime.parse("1975-07-19T01:02:03.000").atZone(ZoneId.systemDefault()).toInstant(); binder.bind(stmt, 1, value); verify(stmt).setDate(1, new Date(value.toEpochMilli())); }
@Test public void dateBinderBindsZonedDateTime() throws SQLException { Binder binder = Binders.dateBinder(); ZonedDateTime value = LocalDateTime.parse("1975-07-19T01:02:03.000").atZone(ZoneOffset.UTC); binder.bind(stmt, 1, value); verify(stmt).setDate(eq(1), eq(new Date(value.toInstant().toEpochMilli())), calendarWithTimeZone(TimeZone.getTimeZone(ZoneOffset.UTC))); }
@Test public void dateBinderBindsOffsetDateTime() throws SQLException { Binder binder = Binders.dateBinder(); OffsetDateTime value = LocalDateTime.parse("1975-07-19T01:02:03.000").atOffset(ZoneOffset.UTC); binder.bind(stmt, 1, value); verify(stmt).setDate(eq(1), eq(new Date(value.toInstant().toEpochMilli())), calendarWithTimeZone(TimeZone.getTimeZone(ZoneOffset.UTC))); }
@Test public void dateBinderBindsNull() throws SQLException { Binder binder = Binders.dateBinder(); binder.bind(stmt, 1, null); verify(stmt).setObject(1, null); }
@Test public void dateBinderBindsObject() throws SQLException { Binder binder = Binders.dateBinder(); binder.bind(stmt, 1, Boolean.TRUE); verify(stmt).setObject(1, Boolean.TRUE); }