下面的截图有
tFixedFlowInput_1 - 定义一个模式与localDateTime(填充)和utcDateTime(无人居住)
tJavaRow_1 - 在localDateTime上执行中/欧洲到UTC时区对话并填充utcDateTime。这是唯一必不可少的部分。
tLogRow_1 - 显示结果
接下来,设置模式为tFixedFlowInput,并添加一些数据
下一页...设置的tJavaRow_1组件
tJavaRow_ 1高级设置/进口低于:
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import java.text.ParseException;
tJavaRow_1基本设置(真正的代码)低于:
注意,try和catch块已被注释掉,从而引发异常和拓蓝招聘可以处理它们。
使用两个SimpleDateFormat实例,每个实例都与时区关联。 localDateTime通过源格式化程序进行分析。然后,使用目标格式化程序将日期转换为UTC并将其作为原始格式的字符串返回。从UTC回到本地是一个微不足道的变化。
String BASE_FORMAT = "dd-MM-yyyy HH:mm";
TimeZone utcTZ = TimeZone.getTimeZone("UTC");
TimeZone ceTZ = TimeZone.getTimeZone("Europe/Amsterdam");
SimpleDateFormat formatUTC = new SimpleDateFormat(BASE_FORMAT);
formatUTC.setTimeZone(utcTZ);
SimpleDateFormat formatCE = new SimpleDateFormat(BASE_FORMAT);
formatCE.setTimeZone(ceTZ);
output_row.localDateTime = input_row.localDateTime;
// Commented out the try and catch, so the exception is thrown to Talend job
//try {
Date dateTimeLocal = formatCE.parse(input_row.localDateTime);
output_row.utcDateTime = formatUTC.format(dateTimeLocal);
//}
//catch (ParseException pe) {
// System.out.println(pe.getMessage());
//}
接下来,tLogRow_1只显示流上的数据。以下是使用示例数据运行的示例。
来源
2016-03-02 01:28:58
dbh
也许这可以帮助你。 http://stackoverflow.com/questions/16663990/casting-date-in-talend-data-integration – error505
不幸的不是。 – PSVSupporter