提交 f9e3bb4a authored 作者: sylvain-ilm's avatar sylvain-ilm

factor timestamp1979

上级 9c97f812
...@@ -1484,18 +1484,18 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -1484,18 +1484,18 @@ public class TestFunctions extends TestBase implements AggregateFunction {
boolean daylight = tz.inDaylightTime(new Date()); boolean daylight = tz.inDaylightTime(new Date());
String tzShortName = tz.getDisplayName(daylight, TimeZone.SHORT); String tzShortName = tz.getDisplayName(daylight, TimeZone.SHORT);
String tzLongName = tz.getID(); String tzLongName = tz.getID();
final Timestamp timestamp1979 = Timestamp.valueOf("1979-11-12 08:12:34.560");
stat.executeUpdate("CREATE TABLE T (X TIMESTAMP(6))"); stat.executeUpdate("CREATE TABLE T (X TIMESTAMP(6))");
stat.executeUpdate("INSERT INTO T VALUES " + stat.executeUpdate("INSERT INTO T VALUES " +
"(TIMESTAMP '1979-11-12 08:12:34.560')"); "(TIMESTAMP '"+timestamp1979.toString()+"')");
stat.executeUpdate("CREATE TABLE U (X TIMESTAMP(6))"); stat.executeUpdate("CREATE TABLE U (X TIMESTAMP(6))");
stat.executeUpdate("INSERT INTO U VALUES " + stat.executeUpdate("INSERT INTO U VALUES " +
"(TIMESTAMP '-100-01-15 14:04:02.120')"); "(TIMESTAMP '-100-01-15 14:04:02.120')");
assertResult("1979-11-12 08:12:34.56", stat, "SELECT X FROM T"); assertResult("1979-11-12 08:12:34.56", stat, "SELECT X FROM T");
assertResult("-100-01-15 14:04:02.12", stat, "SELECT X FROM U"); assertResult("-100-01-15 14:04:02.12", stat, "SELECT X FROM U");
String expected = String.format("%tb", String expected = String.format("%tb", timestamp1979).toUpperCase();
Timestamp.valueOf("1979-11-12 08:12:34.560")).toUpperCase();
assertResult("12-" + expected + "-79 08.12.34.560000 AM", stat, assertResult("12-" + expected + "-79 08.12.34.560000 AM", stat,
"SELECT TO_CHAR(X) FROM T"); "SELECT TO_CHAR(X) FROM T");
assertResult("- / , . ; : text - /", stat, assertResult("- / , . ; : text - /", stat,
...@@ -1544,8 +1544,7 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -1544,8 +1544,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertResult("am", stat, "SELECT TO_CHAR(X, 'pm') FROM T"); assertResult("am", stat, "SELECT TO_CHAR(X, 'pm') FROM T");
assertResult("2", stat, "SELECT TO_CHAR(X, 'D') FROM T"); assertResult("2", stat, "SELECT TO_CHAR(X, 'D') FROM T");
assertResult("2", stat, "SELECT TO_CHAR(X, 'd') FROM T"); assertResult("2", stat, "SELECT TO_CHAR(X, 'd') FROM T");
expected = String.format("%tA", expected = String.format("%tA", timestamp1979);
Timestamp.valueOf("1979-11-12 08:12:34.560"));
expected = expected.substring(0, 1).toUpperCase() + expected.substring(1); expected = expected.substring(0, 1).toUpperCase() + expected.substring(1);
String spaces = " "; String spaces = " ";
String first9 = (expected + spaces).substring(0, 9); String first9 = (expected + spaces).substring(0, 9);
...@@ -1564,16 +1563,14 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -1564,16 +1563,14 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertResult("316", stat, "SELECT TO_CHAR(X, 'DdD') FROM T"); assertResult("316", stat, "SELECT TO_CHAR(X, 'DdD') FROM T");
assertResult("316", stat, "SELECT TO_CHAR(X, 'dDD') FROM T"); assertResult("316", stat, "SELECT TO_CHAR(X, 'dDD') FROM T");
assertResult("316", stat, "SELECT TO_CHAR(X, 'ddd') FROM T"); assertResult("316", stat, "SELECT TO_CHAR(X, 'ddd') FROM T");
expected = String.format("%1$tA, %1$tB %1$te, %1$tY", expected = String.format("%1$tA, %1$tB %1$te, %1$tY", timestamp1979);
Timestamp.valueOf("1979-11-12 08:12:34.560"));
assertResult(expected, stat, assertResult(expected, stat,
"SELECT TO_CHAR(X, 'DL') FROM T"); "SELECT TO_CHAR(X, 'DL') FROM T");
assertResult("11/12/1979", stat, "SELECT TO_CHAR(X, 'DS') FROM T"); assertResult("11/12/1979", stat, "SELECT TO_CHAR(X, 'DS') FROM T");
assertResult("11/12/1979", stat, "SELECT TO_CHAR(X, 'Ds') FROM T"); assertResult("11/12/1979", stat, "SELECT TO_CHAR(X, 'Ds') FROM T");
assertResult("11/12/1979", stat, "SELECT TO_CHAR(X, 'dS') FROM T"); assertResult("11/12/1979", stat, "SELECT TO_CHAR(X, 'dS') FROM T");
assertResult("11/12/1979", stat, "SELECT TO_CHAR(X, 'ds') FROM T"); assertResult("11/12/1979", stat, "SELECT TO_CHAR(X, 'ds') FROM T");
expected = String.format("%1$ta", expected = String.format("%1$ta", timestamp1979);
Timestamp.valueOf("1979-11-12 08:12:34.560"));
assertResult(expected.toUpperCase(), stat, "SELECT TO_CHAR(X, 'DY') FROM T"); assertResult(expected.toUpperCase(), stat, "SELECT TO_CHAR(X, 'DY') FROM T");
assertResult(expected, stat, "SELECT TO_CHAR(X, 'Dy') FROM T"); assertResult(expected, stat, "SELECT TO_CHAR(X, 'Dy') FROM T");
assertResult(expected.toLowerCase(), stat, "SELECT TO_CHAR(X, 'dy') FROM T"); assertResult(expected.toLowerCase(), stat, "SELECT TO_CHAR(X, 'dy') FROM T");
...@@ -1618,8 +1615,7 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -1618,8 +1615,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertResult("11", stat, "SELECT TO_CHAR(X, 'Mm') FROM T"); assertResult("11", stat, "SELECT TO_CHAR(X, 'Mm') FROM T");
assertResult("11", stat, "SELECT TO_CHAR(X, 'mM') FROM T"); assertResult("11", stat, "SELECT TO_CHAR(X, 'mM') FROM T");
assertResult("11", stat, "SELECT TO_CHAR(X, 'mm') FROM T"); assertResult("11", stat, "SELECT TO_CHAR(X, 'mm') FROM T");
expected = String.format("%1$tb", expected = String.format("%1$tb", timestamp1979);
Timestamp.valueOf("1979-11-12 08:12:34.560"));
expected = expected.substring(0, 1).toUpperCase() + expected.substring(1); expected = expected.substring(0, 1).toUpperCase() + expected.substring(1);
assertResult(expected.toUpperCase(), stat, assertResult(expected.toUpperCase(), stat,
"SELECT TO_CHAR(X, 'MON') FROM T"); "SELECT TO_CHAR(X, 'MON') FROM T");
...@@ -1627,8 +1623,7 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -1627,8 +1623,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
"SELECT TO_CHAR(X, 'Mon') FROM T"); "SELECT TO_CHAR(X, 'Mon') FROM T");
assertResult(expected.toLowerCase(), stat, assertResult(expected.toLowerCase(), stat,
"SELECT TO_CHAR(X, 'mon') FROM T"); "SELECT TO_CHAR(X, 'mon') FROM T");
expected = String.format("%1$tB", expected = String.format("%1$tB", timestamp1979);
Timestamp.valueOf("1979-11-12 08:12:34.560"));
expected = (expected + " ").substring(0, 9); expected = (expected + " ").substring(0, 9);
assertResult(expected.toUpperCase(), stat, assertResult(expected.toUpperCase(), stat,
"SELECT TO_CHAR(X, 'MONTH') FROM T"); "SELECT TO_CHAR(X, 'MONTH') FROM T");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论