本文整理汇总了Java中org.embulk.spi.time.TimestampParseException类的典型用法代码示例。如果您正苦于以下问题:Java TimestampParseException类的具体用法?Java TimestampParseException怎么用?Java TimestampParseException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimestampParseException类属于org.embulk.spi.time包,在下文中一共展示了TimestampParseException类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: jrubyParse
import org.embulk.spi.time.TimestampParseException; //导入依赖的package包/类
private Timestamp jrubyParse(String text) throws TimestampParseException {
Timestamp timestamp = null;
TimestampParseException exception = null;
org.embulk.spi.time.TimestampParser parser = null;
for (org.embulk.spi.time.TimestampParser p : jrubyParserList) {
parser = p;
try {
// NOTE: embulk >= 0.8.27 uses new faster jruby timestamp parser, and it supports nano second
// NOTE: embulk < 0.8.27 uses old slower jruby timestamp parser, and it supports micro second
timestamp = parser.parse(text);
break;
} catch (TimestampParseException ex) {
exception = ex;
}
}
if (timestamp == null) {
throw exception;
}
return timestamp;
}
示例2: timestampColumn
import org.embulk.spi.time.TimestampParseException; //导入依赖的package包/类
@Override
public void timestampColumn(Column column) {
String value = row.get(column.getName());
if (value == null) {
pageBuilder.setNull(column);
} else {
try {
Timestamp timestamp = timestampParsers[column.getIndex()]
.parse(value);
pageBuilder.setTimestamp(column, timestamp);
} catch (TimestampParseException e) {
log.error("TimestampParseError: Row: {}", row);
log.error("{}", e);
pageBuilder.setNull(column);
}
}
}
示例3: asTimestamp
import org.embulk.spi.time.TimestampParseException; //导入依赖的package包/类
public static Timestamp asTimestamp(String value, TimestampParser parser) throws DataException
{
try {
return parser.parse(value);
}
catch (TimestampParseException ex) {
throw new DataException(buildErrorMessage("timestamp", value), ex);
}
}
示例4: parse
import org.embulk.spi.time.TimestampParseException; //导入依赖的package包/类
public Timestamp parse(String text) throws TimestampParseException, IllegalArgumentException {
if (!jrubyParserList.isEmpty()) {
return jrubyParse(text);
} else if (!javaParserList.isEmpty()) {
return javaParse(text);
} else {
assert false;
throw new RuntimeException();
}
}
示例5: initTimestampLiteral
import org.embulk.spi.time.TimestampParseException; //导入依赖的package包/类
void initTimestampLiteral(StringLiteral literal)
{
this.yytext = literal.yytext;
String[] formats = {
"%Y-%m-%d %H:%M:%S.%N %z",
"%Y-%m-%d %H:%M:%S.%N",
"%Y-%m-%d %H:%M:%S %z",
"%Y-%m-%d %H:%M:%S",
"%Y-%m-%d %z",
"%Y-%m-%d",
};
Timestamp val = null;
TimestampParseException ex = null;
for (String format : formats) {
try {
TimestampParser timestampParser = createTimestampParser(format, defaultTimeZone);
this.val = timestampParser.parse(literal.val);
break;
}
catch (TimestampParseException e) {
ex = e;
}
}
if (this.val == null) {
throw Throwables.propagate(ex);
}
}
示例6: visitCellValueString
import org.embulk.spi.time.TimestampParseException; //导入依赖的package包/类
@Override
public void visitCellValueString(Column column, Object source, String value) {
Timestamp t;
try {
TimestampParser parser = getTimestampParser(column);
t = parser.parse(value);
} catch (TimestampParseException e) {
doConvertError(column, value, e);
return;
}
pageBuilder.setTimestamp(column, t);
}
示例7: testTimestampOpExpWithString
import org.embulk.spi.time.TimestampParseException; //导入依赖的package包/类
@Test
public void testTimestampOpExpWithString()
{
Parser parser = new Parser(schema);
ParserExp exp;
exp = parser.parse("timestamp = TIMESTAMP '1970-01-01 09:00:01.5 +0900'");
assertTrue(exp.eval(reader));
exp = parser.parse("timestamp = TIMESTAMP '1970-01-01 09:00:01.0 +09:00'");
assertFalse(exp.eval(reader));
exp = parser.parse("timestamp != TIMESTAMP '1970-01-01 09:00:01.0 +0900'");
assertTrue(exp.eval(reader));
exp = parser.parse("timestamp != TIMESTAMP '1970-01-01 09:00:01.5 +0900'");
assertFalse(exp.eval(reader));
exp = parser.parse("timestamp > TIMESTAMP '1970-01-01 09:00:01.0 +0900'");
assertTrue(exp.eval(reader));
exp = parser.parse("timestamp > TIMESTAMP '1970-01-01 09:00:01.5 +0900'");
assertFalse(exp.eval(reader));
exp = parser.parse("timestamp >= TIMESTAMP '1970-01-01 09:00:01.5 +09:00'");
assertTrue(exp.eval(reader));
exp = parser.parse("timestamp >= TIMESTAMP '1970-01-01 09:00:02.0 +09:00'");
assertFalse(exp.eval(reader));
exp = parser.parse("timestamp < TIMESTAMP '1970-01-01 09:00:02.0 +09:00'");
assertTrue(exp.eval(reader));
exp = parser.parse("timestamp < TIMESTAMP '1970-01-01 09:00:01.5 +09:00'");
assertFalse(exp.eval(reader));
exp = parser.parse("timestamp <= TIMESTAMP '1970-01-01 09:00:01.5 +09:00'");
assertTrue(exp.eval(reader));
exp = parser.parse("timestamp <= TIMESTAMP '1970-01-01 09:00:01.0 +09:00'");
assertFalse(exp.eval(reader));
exp = parser.parse("TIMESTAMP '1970-01-01 09:00:01.5 +09:00' = timestamp");
assertTrue(exp.eval(reader));
exp = parser.parse("timestamp = TIMESTAMP '1970-01-01 09:00:01.5 +0900'");
assertTrue(exp.eval(reader));
exp = parser.parse("timestamp = TIMESTAMP '1970-01-01 00:00:01.5'");
assertTrue(exp.eval(reader));
exp = parser.parse("timestamp = TIMESTAMP '1970-01-01 09:00:01 +09:00'");
assertFalse(exp.eval(reader));
exp = parser.parse("timestamp = TIMESTAMP '1970-01-01 00:00:01'");
assertFalse(exp.eval(reader));
exp = parser.parse("timestamp = TIMESTAMP '1970-01-01 +09:00'");
assertFalse(exp.eval(reader));
exp = parser.parse("timestamp = TIMESTAMP '1970-01-01'");
assertFalse(exp.eval(reader));
// auto guess of TIMESTAMP
exp = parser.parse("timestamp = '1970-01-01 09:00:01.5 +0900'");
assertTrue(exp.eval(reader));
exp = parser.parse("'1970-01-01 09:00:01.5 +0900' = timestamp");
assertTrue(exp.eval(reader));
try {
parser.parse("timestamp = '1970:01:01'");
assertTrue(false);
}
catch (TimestampParseException ex) {
}
try {
parser.parse("timestamp START_WITH '1970-01-01 09:00:01.5 +0900'");
assertTrue(false);
}
catch (ConfigException e) {
}
}