下面列出了java.sql.Time#valueOf ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Test
public void test19() {
Time t = Time.valueOf("08:30:59");
Time t2 = new Time(t.getTime());
assertFalse(t.after(t2), "Error t.after(t2) = true");
assertFalse(t2.after(t), "Error t2.after(t) = true");
}
/**
* 文字列を{@link Time}に変換します。
*
* @param str
* 文字列
* @return 変換された{@link Time}
*/
protected static Time toSqlTimeJdbcEscape(final String str) {
try {
return Time.valueOf(str);
} catch (final IllegalArgumentException ex) {
return null;
}
}
@Test
public void testTimeFormat() throws Exception {
Oracle11Dialect dialect = new Oracle11Dialect();
SqlLogFormattingVisitor visitor = dialect.getSqlLogFormattingVisitor();
TimeWrapper wrapper = new TimeWrapper(Time.valueOf("01:23:45"));
assertEquals("time'01:23:45'", wrapper.accept(visitor, new ConvertToLogFormatFunction(), null));
}
/**
* Converts the string value to the given type
*
* @param dataType the data type
* @param value the value
* @return the string value to the given type
*/
private Object convertDataType(DataType dataType, String value) {
try {
switch (dataType) {
case BIGINT:
return Long.parseLong(value);
case INTEGER:
case SMALLINT:
return Integer.parseInt(value);
case REAL:
return Float.parseFloat(value);
case NUMERIC:
case FLOAT8:
return Double.parseDouble(value);
case TEXT:
case VARCHAR:
case BPCHAR:
return value;
case BOOLEAN:
return Boolean.parseBoolean(value);
case DATE:
return Date.valueOf(value);
case TIMESTAMP:
return Timestamp.valueOf(value);
case TIME:
return Time.valueOf(value);
case BYTEA:
return value.getBytes();
default:
throw new UnsupportedTypeException(String.format("DataType %s unsupported", dataType));
}
} catch (NumberFormatException nfe) {
throw new IllegalStateException(String.format("failed to parse number data %s for type %s", value, dataType));
}
}
@Test(dataProvider = "invalidTimeValues",
expectedExceptions = IllegalArgumentException.class)
public void test16(String time) throws Exception {
Time.valueOf(time);
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void test08() {
Time t = Time.valueOf("08:30:59");
t.getDate();
}
@Test
public void test15() {
Time t = Time.valueOf("08:30:59");
Time t2 = new Time(t.getTime());
assertTrue(t.equals(t2) && t2.equals(t), "Error t != t2");
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void test01() {
Time t = Time.valueOf("08:30:59");
t.getYear();
}
@Test
public void test17() {
Time t = Time.valueOf("08:30:59");
assertFalse(t.after(t), "Error t.after(t) = true");
}
@Test(dataProvider = "invalidTimeValues",
expectedExceptions = IllegalArgumentException.class)
public void test16(String time) throws Exception {
Time.valueOf(time);
}
@Test
public void test20() {
Time t = Time.valueOf("08:30:59");
assertFalse(t.before(t), "Error t.before(t) = true");
}
@Test(expectedExceptions = NullPointerException.class)
public void test11() throws Exception {
LocalTime ld = null;
Time.valueOf(ld);
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void test03() {
Time t = Time.valueOf("08:30:59");
t.getDay();
}
private Time convertToTime(ObjectMapper mapper, JsonNode jsonNode) {
return Time.valueOf(convertToLocalTime(mapper, jsonNode));
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void test05() {
Time t = Time.valueOf("08:30:59");
t.setYear(8);
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void test06() {
Time t = Time.valueOf("08:30:59");
t.setMonth(8);
}
@Test
public void test15() {
Time t = Time.valueOf("08:30:59");
Time t2 = new Time(t.getTime());
assertTrue(t.equals(t2) && t2.equals(t), "Error t != t2");
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void test07() {
Time t = Time.valueOf("08:30:59");
t.setDate(30);
}
@Test
public void test20() {
Time t = Time.valueOf("08:30:59");
assertFalse(t.before(t), "Error t.before(t) = true");
}
@Test
public void test21() {
Time t = Time.valueOf("08:30:59");
Time t2 = new Time(System.currentTimeMillis());
assertTrue(t.before(t2), "Error t.before(t2) = false");
}