本文整理汇总了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;
}
开发者ID:sonots,项目名称:embulk-filter-timestamp_format,代码行数:22,代码来源:TimestampParser.java
示例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);
}
}
}
开发者ID:mikoto2000,项目名称:embulk-input-salesforce_bulk,代码行数:18,代码来源:SalesforceBulkInputPlugin.java
示例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);
}
}
开发者ID:hiroyuki-sato,项目名称:embulk-parser-jsonpath,代码行数:10,代码来源:StringCast.java
示例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();
}
}
开发者ID:sonots,项目名称:embulk-filter-timestamp_format,代码行数:11,代码来源:TimestampParser.java
示例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);
}
}
开发者ID:sonots,项目名称:embulk-filter-row,代码行数:28,代码来源:ParserLiteral.java
示例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);
}
开发者ID:hishidama,项目名称:embulk-parser-poi_excel,代码行数:13,代码来源:TimestampCellVisitor.java
示例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) {
}
}
开发者ID:sonots,项目名称:embulk-filter-row,代码行数:73,代码来源:TestParser.java
注:本文中的org.embulk.spi.time.TimestampParseException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论