java.sql.Time Java Examples

The following examples show how to use java.sql.Time. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DbSink.java    From morpheus-core with Apache License 2.0 6 votes vote down vote up
@Override
void apply(PreparedStatement stmt, int stmtIndex, DataFrameRow<R, C> row) {
    final R rowKey = row.key();
    try {
        switch (rowKeyType) {
            case BIT:       stmt.setBoolean(stmtIndex, rowKeyMapper.applyAsBoolean(rowKey));             break;
            case BOOLEAN:   stmt.setBoolean(stmtIndex, rowKeyMapper.applyAsBoolean(rowKey));             break;
            case TINYINT:   stmt.setInt(stmtIndex, rowKeyMapper.applyAsInt(rowKey));                     break;
            case SMALLINT:  stmt.setInt(stmtIndex, rowKeyMapper.applyAsInt(rowKey));                     break;
            case FLOAT:     stmt.setDouble(stmtIndex, rowKeyMapper.applyAsDouble(rowKey));               break;
            case INTEGER:   stmt.setInt(stmtIndex, rowKeyMapper.applyAsInt(rowKey));                     break;
            case BIGINT:    stmt.setLong(stmtIndex, rowKeyMapper.applyAsLong(rowKey));                   break;
            case DOUBLE:    stmt.setDouble(stmtIndex, rowKeyMapper.applyAsDouble(rowKey));               break;
            case DECIMAL:   stmt.setDouble(stmtIndex, rowKeyMapper.applyAsDouble(rowKey));               break;
            case VARCHAR:   stmt.setString(stmtIndex, (String)rowKeyMapper.apply(rowKey));          break;
            case DATE:      stmt.setDate(stmtIndex, (Date)rowKeyMapper.apply(rowKey));              break;
            case TIME:      stmt.setTime(stmtIndex, (Time)rowKeyMapper.apply(rowKey));              break;
            case DATETIME:  stmt.setTimestamp(stmtIndex, (Timestamp)rowKeyMapper.apply(rowKey));    break;
            default:    throw new IllegalStateException("Unsupported column type:" + rowKeyType);
        }
    } catch (Exception ex) {
        throw new DataFrameException("Failed to apply row key to SQL statement at " + rowKey, ex);
    }
}
 
Example #2
Source File: TestSQLDataImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void writeSQL(SQLOutput stream) throws SQLException {

    stream.writeString((String) types[stringPos]);
    stream.writeDate((Date) types[datePos]);
    stream.writeTime((Time) types[timePos]);
    stream.writeTimestamp((Timestamp) types[timestampPos]);
    stream.writeInt((Integer) types[intPos]);
    stream.writeLong((Long) types[longPos]);
    stream.writeShort((Short) types[shortPos]);
    stream.writeBigDecimal((BigDecimal) types[bigDecimalPos]);
    stream.writeDouble((Double) types[doublePos]);
    stream.writeBoolean((Boolean) types[booleanPos]);
    stream.writeFloat((Float) types[floatPos]);
    stream.writeByte((Byte) types[bytePos]);
    stream.writeBytes((byte[]) types[bytesPos]);
}
 
Example #3
Source File: DateUtilTest.java    From onetwo with Apache License 2.0 6 votes vote down vote up
@Test
public void testSqlTime(){
	Date now = new Date();
	Time time = new Time(now.getTime());
   	Time nowTime = new Time(now.getHours(), now.getMinutes(), now.getSeconds());
	String str = DateUtils.formatDateTime(time);
	System.out.println("time:"+DateUtils.format("h:mm a", new Date()));
	System.out.println("time:"+str);
	System.out.println("time:"+now.getTime());
	System.out.println("time:"+time.getTime());
	System.out.println("nowTime:"+nowTime.getTime());
	
	LocalTime jodaTime = LocalTime.fromDateFields(now);
	System.out.println("jodaTime:"+jodaTime.toString());
	System.out.println("jodaTime:"+now.getTime());
	System.out.println("jodaTime:"+jodaTime.getMillisOfDay());
}
 
Example #4
Source File: EncodingSpecificDatatypeCoderTest.java    From jaybird with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void decodeTime_calendar_boolean() throws Exception {
    final Calendar calendar = Calendar.getInstance();
    final Time value = new Time(System.currentTimeMillis());
    final Time response1 = new Time(System.currentTimeMillis() - 60 * 60 * 1000);
    final Time response2 = new Time(System.currentTimeMillis() + 60 * 60 * 1000);

    context.checking(new Expectations() {{
        oneOf(parentCoder).decodeTime(value, calendar, false); will(returnValue(response1));
        oneOf(parentCoder).decodeTime(value, calendar, true); will(returnValue(response2));
    }});

    Time result1 = coder.decodeTime(value, calendar, false);
    Time result2 = coder.decodeTime(value, calendar, true);

    assertSame(response1, result1);
    assertSame(response2, result2);
}
 
Example #5
Source File: ManyMethods.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
public String isNull(Time value)
{
	if (value == null)
		return "Time is null";
	else
		return "Time is not null";
}
 
Example #6
Source File: DelegatingCallableStatement.java    From commons-dbcp with Apache License 2.0 5 votes vote down vote up
@Override
public Time getTime(final String parameterName) throws SQLException {
    checkOpen();
    try {
        return getDelegateCallableStatement().getTime(parameterName);
    } catch (final SQLException e) {
        handleException(e);
        return null;
    }
}
 
Example #7
Source File: SqlTimeParserTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Time[] getValidTestResults() {
	return new Time[] {
		Time.valueOf("00:00:00"), Time.valueOf("02:42:25"), Time.valueOf("14:15:51"),
		Time.valueOf("18:00:45"), Time.valueOf("23:59:58"), Time.valueOf("0:0:0")
	};
}
 
Example #8
Source File: SQLTimestamp.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
	getTime returns the time portion of the timestamp
	Date is set to 1970-01-01
	Since Time is a JDBC object we use the JDBC definition
	for the date portion.  See JDBC API Tutorial, 47.3.12.
	@exception StandardException thrown on failure
 */
public Time	getTime( Calendar cal) throws StandardException
{
	if (isNull())
		return null;
       
       // Derby's SQL TIMESTAMP type supports resolution
       // to nano-seconds so ensure the Time object
       // maintains that since it has milli-second
       // resolutiuon.
       return SQLTime.getTime(cal, encodedTime, nanos);
}
 
Example #9
Source File: BindBean2SharedPreferences.java    From kripton with Apache License 2.0 5 votes vote down vote up
/**
 * for attribute valueTimeList serialization
 */
protected String serializeValueTimeList(List<Time> value) {
  if (value==null) {
    return null;
  }
  KriptonJsonContext context=KriptonBinder.jsonBind();
  try (KriptonByteArrayOutputStream stream=new KriptonByteArrayOutputStream(); JacksonWrapperSerializer wrapper=context.createSerializer(stream)) {
    JsonGenerator jacksonSerializer=wrapper.jacksonGenerator;
    jacksonSerializer.writeStartObject();
    int fieldCount=0;
    if (value!=null)  {
      fieldCount++;
      int n=value.size();
      Time item;
      // write wrapper tag
      jacksonSerializer.writeFieldName("valueTimeList");
      jacksonSerializer.writeStartArray();
      for (int i=0; i<n; i++) {
        item=value.get(i);
        if (item==null) {
          jacksonSerializer.writeNull();
        } else {
          jacksonSerializer.writeString(SQLTimeUtils.write(item));
        }
      }
      jacksonSerializer.writeEndArray();
    }
    jacksonSerializer.writeEndObject();
    jacksonSerializer.flush();
    return stream.toString();
  } catch(Exception e) {
    e.printStackTrace();
    throw(new KriptonRuntimeException(e.getMessage()));
  }
}
 
Example #10
Source File: OpPlusTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void test_binaryPlusWithTimeConverted() {

	final SimpleDateFormat format = new SimpleDateFormat("hh :--: mm :--: ss", Locale.ENGLISH);

	GenericConversionService conversionService = new GenericConversionService();
	conversionService.addConverter(new Converter<Time, String>() {
		@Override
		public String convert(Time source) {
			return format.format(source);
		}
	});

	StandardEvaluationContext evaluationContextConverter = new StandardEvaluationContext();
	evaluationContextConverter.setTypeConverter(new StandardTypeConverter(conversionService));

	ExpressionState expressionState = new ExpressionState(evaluationContextConverter);

	Time time = new Time(new Date().getTime());

	VariableReference var = new VariableReference("timeVar", -1);
	var.setValue(expressionState, time);

	StringLiteral n2 = new StringLiteral("\" is now\"", -1, "\" is now\"");
	OpPlus o = new OpPlus(-1, var, n2);
	TypedValue value = o.getValueInternal(expressionState);

	assertEquals(String.class, value.getTypeDescriptor().getObjectType());
	assertEquals(String.class, value.getTypeDescriptor().getType());
	assertEquals(format.format(time) + " is now", value.getValue());
}
 
Example #11
Source File: TimeTypeAdapter.java    From framework with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override public synchronized Time read(JsonReader in) throws IOException {
  if (in.peek() == JsonToken.NULL) {
    in.nextNull();
    return null;
  }
  try {
    Date date = format.parse(in.nextString());
    return new Time(date.getTime());
  } catch (ParseException e) {
    throw new JsonSyntaxException(e);
  }
}
 
Example #12
Source File: TestField.java    From presto with Apache License 2.0 5 votes vote down vote up
@Test
public void testTime()
{
    Type type = TIME;
    Time expected = new Time(new GregorianCalendar(1970, 0, 1, 12, 30, 0).getTime().getTime());
    Field f1 = new Field(70200000L, type);
    assertEquals(f1.getTime(), expected);
    assertEquals(f1.getObject(), expected);
    assertEquals(f1.getType(), type);

    Field f2 = new Field(f1);
    assertEquals(f2, f1);
}
 
Example #13
Source File: CopyOptions.java    From enkan with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * クラスに対応するデフォルトのコンバータを探します。
 *
 * @param clazz
 *            クラス
 * @return コンバータ
 */
protected Converter findDefaultConverter(final Class<?> clazz) {
    if (clazz == java.sql.Date.class) {
        return DEFAULT_DATE_CONVERTER;
    }
    if (clazz == Time.class) {
        return DEFAULT_TIME_CONVERTER;
    }
    if (java.util.Date.class.isAssignableFrom(clazz)) {
        return DEFAULT_TIMESTAMP_CONVERTER;
    }
    return null;
}
 
Example #14
Source File: CallableStatement.java    From r-course with MIT License 5 votes vote down vote up
/**
 * @see java.sql.CallableStatement#getTime(int)
 */
public Time getTime(int parameterIndex) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        ResultSetInternalMethods rs = getOutputParameters(parameterIndex);

        Time retValue = rs.getTime(mapOutputParameterIndexToRsIndex(parameterIndex));

        this.outputParamWasNull = rs.wasNull();

        return retValue;
    }
}
 
Example #15
Source File: TableDataUtils.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static String getTimeAsString(Time time) {
    if (null == time) {
        return null;
    }
    Date date = new Date(time.getTime());
    return getDateAsString(date);
}
 
Example #16
Source File: CourseManagementAdministrationHibernateImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public Meeting newSectionMeeting(String sectionEid, String location, Time startTime, Time finishTime, String notes) {
	Section section = (Section)getObjectByEid(sectionEid, SectionCmImpl.class.getName());
	MeetingCmImpl meeting = new MeetingCmImpl(section, location, startTime, finishTime, notes);
	meeting.setCreatedBy(authn.getUserEid());
	meeting.setCreatedDate(new Date());
	Set<Meeting> meetings = section.getMeetings();
	if(meetings == null) {
		meetings = new HashSet<Meeting>();
		section.setMeetings(meetings);
	}
	return meeting;
}
 
Example #17
Source File: JdbcTypesConverter.java    From scriptella-etl with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the {@link java.util.Date} or its descendant as a statement parameter.
 */
protected void setDateObject(final PreparedStatement ps, final int index, final Date date) throws SQLException {
    if (date instanceof Timestamp) {
        ps.setTimestamp(index, (Timestamp) date);
    } else if (date instanceof java.sql.Date) {
        ps.setDate(index, (java.sql.Date) date);
    } else if (date instanceof Time) {
        ps.setTime(index, (Time) date);
    } else {
        ps.setTimestamp(index, new Timestamp(date.getTime()));
    }
}
 
Example #18
Source File: Wrapper41Test.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
private void    vetWrappedInteger( Wrapper41 wrapper, int colID, String colName ) throws Exception
{
    vetWrapperOK
        (
         wrapper,
         colID,
         colName,
         _rowOfNulls ? null : "1",
         new Class[] { String.class, BigDecimal.class, Byte.class, Short.class, Integer.class, Long.class, Number.class, Object.class }
         );
    vetWrapperOK
        (
         wrapper,
         colID,
         colName,
         _rowOfNulls ? null : "1.0",
         new Class[] { Float.class, Double.class }
         );
    vetWrapperOK
        (
         wrapper,
         colID,
         colName,
         _rowOfNulls ? null : "true",
         new Class[] { Boolean.class }
         );
    
    vetNoWrapper
        (
         wrapper,
         colID,
         colName,
         new Class[] { Date.class, Time.class, Timestamp.class, Blob.class, Clob.class, _byteArrayClass, getClass() }
         );
}
 
Example #19
Source File: HBaseTypeUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Deserialize byte array to Java Object with the given type.
 */
public static Object deserializeToObject(byte[] value, int typeIdx, Charset stringCharset) {
	switch (typeIdx) {
		case 0: // byte[]
			return value;
		case 1: // String
			return new String(value, stringCharset);
		case 2: // byte
			return value[0];
		case 3:
			return Bytes.toShort(value);
		case 4:
			return Bytes.toInt(value);
		case 5:
			return Bytes.toLong(value);
		case 6:
			return Bytes.toFloat(value);
		case 7:
			return Bytes.toDouble(value);
		case 8:
			return Bytes.toBoolean(value);
		case 9: // sql.Timestamp encoded as long
			return new Timestamp(Bytes.toLong(value));
		case 10: // sql.Date encoded as long
			return new Date(Bytes.toLong(value));
		case 11: // sql.Time encoded as long
			return new Time(Bytes.toLong(value));
		case 12:
			return Bytes.toBigDecimal(value);
		case 13:
			return new BigInteger(value);

		default:
			throw new IllegalArgumentException("unsupported type index:" + typeIdx);
	}
}
 
Example #20
Source File: Cursor.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
private Time getTIME(int column, Calendar cal) throws SqlException {
    try {
        return com.splicemachine.db.client.am.DateTime.timeBytesToTime(dataBuffer_,
                columnDataPosition_[column - 1],
                cal,
                charsetName_[column - 1]);
    } catch (UnsupportedEncodingException e) {
         throw new SqlException(agent_.logWriter_, 
             new ClientMessageId(SQLState.UNSUPPORTED_ENCODING),
             "TIME", "java.sql.Time", e);
    }
}
 
Example #21
Source File: SectionDecorator.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Compares SectionDecorators by the section's first meeting times.
 *
 * @param sortAscending
 * @return
 */
public static final Comparator<SectionDecorator> getTimeComparator(final boolean sortAscending) {
    return new Comparator<SectionDecorator>() {
        public int compare(SectionDecorator section1, SectionDecorator section2) {

                // First compare the category name, then compare the time
                int categoryNameComparison = section1.getCategory().compareTo(section2.getCategory());
                if(categoryNameComparison == 0) {
                    // These are in the same category, so compare by the first meeting time
                    List meetings1 = section1.getDecoratedMeetings();
                    List meetings2 = section2.getDecoratedMeetings();

                    MeetingDecorator meeting1 = (MeetingDecorator)meetings1.get(0);
                    MeetingDecorator meeting2 = (MeetingDecorator)meetings2.get(0);

                    Time startTime1 = meeting1.getStartTime();
                    Time startTime2 = meeting2.getStartTime();

                    if(startTime1 == null && startTime2 != null) {
                        return sortAscending? -1 : 1 ;
                    }
                    if(startTime2 == null && startTime1 != null) {
                        return sortAscending? 1 : -1 ;
                    }

                    if(startTime1 == null && startTime2 == null ||
                            startTime1.equals(startTime2)) {
                        return getTitleComparator(sortAscending).compare(section1, section2);
                    }
                    return sortAscending ? startTime1.compareTo(startTime2) : startTime2.compareTo(startTime1);
                } else {
                    return categoryNameComparison;
                }
        }
    };
}
 
Example #22
Source File: SectionManagerImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void updateSection(String sectionUuid, String title,
		Integer maxEnrollments, String location, Time startTime,
		Time endTime, boolean monday, boolean tuesday,
		boolean wednesday, boolean thursday, boolean friday,
		boolean saturday, boolean sunday) {
	// Create a list of meetings with a single meeting
	List<Meeting> meetings = new ArrayList<Meeting>();
	MeetingImpl meeting = new MeetingImpl(location, startTime, endTime, monday, tuesday, wednesday, thursday, friday, saturday, sunday);
	meetings.add(meeting);

	// Update the section with a single meeting
	updateSection(sectionUuid, title, maxEnrollments, meetings);
}
 
Example #23
Source File: HBaseRowInputFormat.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private Object deserialize(byte[] value, int typeIdx) {
	switch (typeIdx) {
		case 0: // byte[]
			return value;
		case 1:
			return new String(value, stringCharset);
		case 2: // byte
			return value[0];
		case 3:
			return Bytes.toShort(value);
		case 4:
			return Bytes.toInt(value);
		case 5:
			return Bytes.toLong(value);
		case 6:
			return Bytes.toFloat(value);
		case 7:
			return Bytes.toDouble(value);
		case 8:
			return Bytes.toBoolean(value);
		case 9: // sql.Timestamp encoded as long
			return new Timestamp(Bytes.toLong(value));
		case 10: // sql.Date encoded as long
			return new Date(Bytes.toLong(value));
		case 11: // sql.Time encoded as long
			return new Time(Bytes.toLong(value));
		case 12:
			return Bytes.toBigDecimal(value);
		case 13:
			return new BigInteger(value);

		default:
			throw new IllegalArgumentException("Unknown type index " + typeIdx);
	}
}
 
Example #24
Source File: TimeRandomizersTest.java    From easy-random with MIT License 5 votes vote down vote up
static Object[][] generateSeededRandomizersAndTheirExpectedValues() {
    Calendar expectedCalendar = Calendar.getInstance();
    expectedCalendar.setTime(new Date(1718736844570L));

    GregorianCalendar expectedGregorianCalendar = new GregorianCalendar();
    expectedGregorianCalendar.setTimeInMillis(5106534569952410475L);

    return new Object[][] {
            { aNewDurationRandomizer(SEED), Duration.of(72L, ChronoUnit.HOURS) },
            { aNewDurationRandomizer(SEED, ChronoUnit.MINUTES), Duration.of(72L, ChronoUnit.MINUTES) },
            { aNewDurationRandomizer(SEED, ChronoUnit.MILLIS), Duration.of(72L, ChronoUnit.MILLIS) },
            { aNewLocalDateRandomizer(SEED), LocalDate.of(2024, Month.MARCH, 20) },
            { aNewMonthDayRandomizer(SEED), MonthDay.of(Month.MARCH, 20) },
            { aNewLocalTimeRandomizer(SEED), LocalTime.of(16, 42, 58) },
            { aNewPeriodRandomizer(SEED), Period.of(2024, 3, 20) },
            { aNewYearRandomizer(SEED), Year.of(2024) },
            { aNewYearMonthRandomizer(SEED), YearMonth.of(2024, Month.MARCH) },
            { aNewZoneOffsetRandomizer(SEED), ZoneOffset.ofTotalSeconds(28923) },
            { aNewCalendarRandomizer(SEED), expectedCalendar },
            { aNewDateRandomizer(SEED), new Date(1718736844570L) },
            { aNewGregorianCalendarRandomizer(SEED), expectedGregorianCalendar },
            { aNewInstantRandomizer(SEED), Instant.ofEpochSecond(1718736844L, 570000000) },
            { aNewLocalDateTimeRandomizer(SEED), LocalDateTime.of(2024, Month.MARCH, 20, 16, 42, 58, 0) },
            { aNewOffsetDateTimeRandomizer(SEED), OffsetDateTime.of(of(2024, Month.MARCH, 20, 16, 42, 58, 0), ofTotalSeconds(28923)) },
            { aNewOffsetTimeRandomizer(SEED), OffsetTime.of(LocalTime.of(16, 42, 58, 0), ofTotalSeconds(28923)) },
            { aNewSqlDateRandomizer(SEED), new java.sql.Date(1718736844570L) },
            { aNewSqlTimeRandomizer(SEED), new Time(1718736844570L) },
            { aNewSqlTimestampRandomizer(SEED), new Timestamp(1718736844570L) }
    };
}
 
Example #25
Source File: PgRow.java    From postgres-async-driver with Apache License 2.0 4 votes vote down vote up
@Override
public Time getTime(int index) {
    return dataConverter.toTime(columns[index].getType(), data.getValue(index));
}
 
Example #26
Source File: CallableStatementStub.java    From FHIR with Apache License 2.0 4 votes vote down vote up
@Override
public Time getTime(int parameterIndex, Calendar cal) throws SQLException {
    // Stub Only
    return null;
}
 
Example #27
Source File: ColumnValueConverter.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public void setTime(OptimizedElementArray row, int columnIndex, Time x)
    throws SQLException {
  throw Converters.newTypeConversionException(getType().toString(), "Time");
}
 
Example #28
Source File: JdbcResultSet.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public Time getTime(String colLb, Calendar cal) throws SQLException {
    return getTypedValue(colLb, Time.class);
}
 
Example #29
Source File: StubJoinRowSetImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void updateTime(String columnLabel, Time x) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example #30
Source File: JavatimeTest.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Throwable {
    int N = 10000;
    long t1970 = new java.util.Date(70, 0, 01).getTime();
    Random r = new Random();
    for (int i = 0; i < N; i++) {
        int days  = r.nextInt(50) * 365 + r.nextInt(365);
        long secs = t1970 + days * 86400 + r.nextInt(86400);
        int nanos = r.nextInt(NANOS_PER_SECOND);
        int nanos_ms = nanos / 1000000 * 1000000; // millis precision
        long millis = secs * 1000 + r.nextInt(1000);

        LocalDateTime ldt = LocalDateTime.ofEpochSecond(secs, nanos, ZoneOffset.UTC);
        LocalDateTime ldt_ms = LocalDateTime.ofEpochSecond(secs, nanos_ms, ZoneOffset.UTC);
        Instant inst = Instant.ofEpochSecond(secs, nanos);
        Instant inst_ms = Instant.ofEpochSecond(secs, nanos_ms);
        //System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);

        /////////// Timestamp ////////////////////////////////
        Timestamp ta = new Timestamp(millis);
        ta.setNanos(nanos);
        if (!isEqual(ta.toLocalDateTime(), ta)) {
            System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
            print(ta.toLocalDateTime(), ta);
            throw new RuntimeException("FAILED: j.s.ts -> ldt");
        }
        if (!isEqual(ldt, Timestamp.valueOf(ldt))) {
            System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
            print(ldt, Timestamp.valueOf(ldt));
            throw new RuntimeException("FAILED: ldt -> j.s.ts");
        }
        Instant inst0 = ta.toInstant();
        if (ta.getTime() != inst0.toEpochMilli() ||
            ta.getNanos() != inst0.getNano() ||
            !ta.equals(Timestamp.from(inst0))) {
            System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
            throw new RuntimeException("FAILED: j.s.ts -> instant -> j.s.ts");
        }
        inst = Instant.ofEpochSecond(secs, nanos);
        Timestamp ta0 = Timestamp.from(inst);
        if (ta0.getTime() != inst.toEpochMilli() ||
            ta0.getNanos() != inst.getNano() ||
            !inst.equals(ta0.toInstant())) {
            System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
            throw new RuntimeException("FAILED: instant -> timestamp -> instant");
        }

        ////////// java.sql.Date /////////////////////////////
        // j.s.d/t uses j.u.d.equals() !!!!!!!!
        java.sql.Date jsd = new java.sql.Date(millis);
        if (!isEqual(jsd.toLocalDate(), jsd)) {
            System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
            print(jsd.toLocalDate(), jsd);
            throw new RuntimeException("FAILED: j.s.d -> ld");
        }
        LocalDate ld = ldt.toLocalDate();
        if (!isEqual(ld, java.sql.Date.valueOf(ld))) {
            System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
            print(ld, java.sql.Date.valueOf(ld));
            throw new RuntimeException("FAILED: ld -> j.s.d");
        }
        ////////// java.sql.Time /////////////////////////////
        java.sql.Time jst = new java.sql.Time(millis);
        if (!isEqual(jst.toLocalTime(), jst)) {
            System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
            print(jst.toLocalTime(), jst);
            throw new RuntimeException("FAILED: j.s.t -> lt");
        }
        // millis precision
        LocalTime lt = ldt_ms.toLocalTime();
        if (!isEqual(lt, java.sql.Time.valueOf(lt))) {
            System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
            print(lt, java.sql.Time.valueOf(lt));
            throw new RuntimeException("FAILED: lt -> j.s.t");
        }
    }
    System.out.println("Passed!");
}