@Test(expected = DataException.class) public void testFromLogicalInvalidHasTimeComponents() { Date.fromLogical(Date.SCHEMA, EPOCH_PLUS_TIME_COMPONENT.getTime()); }
public static int fromLogical(Schema schema, java.util.Date value) { if (schema.name() == null || !(schema.name().equals(LOGICAL_NAME))) throw new DataException("Requested conversion of Date object but the schema does not match."); Calendar calendar = Calendar.getInstance(UTC); calendar.setTime(value); if (calendar.get(Calendar.HOUR_OF_DAY) != 0 || calendar.get(Calendar.MINUTE) != 0 || calendar.get(Calendar.SECOND) != 0 || calendar.get(Calendar.MILLISECOND) != 0) { throw new DataException("Kafka Connect Date type should not have any time fields set to non-zero values."); } long unixMillis = calendar.getTimeInMillis(); return (int) (unixMillis / MILLIS_PER_DAY); }
Date { public static int fromLogical(Schema schema, java.util.Date value) { if (schema.name() == null || !(schema.name().equals(LOGICAL_NAME))) throw new DataException("Requested conversion of Date object but the schema does not match."); Calendar calendar = Calendar.getInstance(UTC); calendar.setTime(value); if (calendar.get(Calendar.HOUR_OF_DAY) != 0 || calendar.get(Calendar.MINUTE) != 0 || calendar.get(Calendar.SECOND) != 0 || calendar.get(Calendar.MILLISECOND) != 0) { throw new DataException("Kafka Connect Date type should not have any time fields set to non-zero values."); } long unixMillis = calendar.getTimeInMillis(); return (int) (unixMillis / MILLIS_PER_DAY); } }
Date { public static int fromLogical(Schema schema, java.util.Date value) { if (schema.name() == null || !(schema.name().equals(LOGICAL_NAME))) throw new DataException("Requested conversion of Date object but the schema does not match."); Calendar calendar = Calendar.getInstance(UTC); calendar.setTime(value); if (calendar.get(Calendar.HOUR_OF_DAY) != 0 || calendar.get(Calendar.MINUTE) != 0 || calendar.get(Calendar.SECOND) != 0 || calendar.get(Calendar.MILLISECOND) != 0) { throw new DataException("Kafka Connect Date type should not have any time fields set to non-zero values."); } long unixMillis = calendar.getTimeInMillis(); return (int) (unixMillis / MILLIS_PER_DAY); }  }
Date { public static int fromLogical(Schema schema, java.util.Date value) { if (schema.name() == null || !(schema.name().equals(LOGICAL_NAME))) throw new DataException("Requested conversion of Date object but the schema does not match."); Calendar calendar = Calendar.getInstance(UTC); calendar.setTime(value); if (calendar.get(Calendar.HOUR_OF_DAY) != 0 || calendar.get(Calendar.MINUTE) != 0 || calendar.get(Calendar.SECOND) != 0 || calendar.get(Calendar.MILLISECOND) != 0) { throw new DataException("Kafka Connect Date type should not have any time fields set to non-zero values."); } long unixMillis = calendar.getTimeInMillis(); return (int) (unixMillis / MILLIS_PER_DAY); }  static SchemaBuilder builder(); static int fromLogical(Schema schema, java.util.Date value); static java.util.Date toLogical(Schema schema, int value); }
Date { public static int fromLogical(Schema schema, java.util.Date value) { if (schema.name() == null || !(schema.name().equals(LOGICAL_NAME))) throw new DataException("Requested conversion of Date object but the schema does not match."); Calendar calendar = Calendar.getInstance(UTC); calendar.setTime(value); if (calendar.get(Calendar.HOUR_OF_DAY) != 0 || calendar.get(Calendar.MINUTE) != 0 || calendar.get(Calendar.SECOND) != 0 || calendar.get(Calendar.MILLISECOND) != 0) { throw new DataException("Kafka Connect Date type should not have any time fields set to non-zero values."); } long unixMillis = calendar.getTimeInMillis(); return (int) (unixMillis / MILLIS_PER_DAY); }  static SchemaBuilder builder(); static int fromLogical(Schema schema, java.util.Date value); static java.util.Date toLogical(Schema schema, int value); static final String LOGICAL_NAME; static final Schema SCHEMA; }