두 개의 열을 결합합니다. 날짜와 시간. 핫 코딩 된 날짜와 시간을 전달하면 제대로 작동하지만 열을 통해 전달하면 오류가 발생합니다.
구문 분석 할 수없는 날짜 : '1992 년 5 월 5 일'
나는 이미 이것을 시도했다 :
MaterialCodeCSV.xdate == null ?
TalendDate.parseDate("yyyy-MM-dd HH:mm:ss", TalendDate.getDate("yyyy-MM-dd HH:mm:ss")) :
TalendDate.parseDateLocale("yyyy/mm/dd HH:mm:ss",MaterialCodeCSV.xdate.toString() + MaterialCodeCSV.xtime.toString(),"EN");
Talend의 Java 코드 :
잘못된 데이터 유형을 사용하면 날짜 처리가 약간 까다로울 수 있습니다. 나는 당신이 Date
. 이 방법에는 몇 가지 오류가 있습니다.
MaterialCodeCSV.xdate == null ?
TalendDate.parseDate("yyyy-MM-dd HH:mm:ss", TalendDate.getDate("yyyy-MM-dd HH:mm:ss")) :
TalendDate.parseDateLocale("yyyy/mm/dd H:mm:ss",MaterialCodeCSV.xdate.toString()+ MaterialCodeCSV.xtime.toString(),"EN");
MaterialCodeCSV.xdate == null
당신은 날짜를 생성하고 즉시 다시 구문 분석? 불필요하게 복잡하고 비효율적으로 보입니다. 이것을 다음으로 변경하십시오.TalendDate.getCurrentDate()
xdate
is not null, you just concat xdate
and xtime
, use toString()
and try to parse this. Again, this seems unneccesary complex. If I just assume now and xdate
and xtime
are already Date
fields, you could write it as this: MaterialCodeCSV.xdate + MaterialCodeCSV.xtime
.String
fields, you have to make sure that xdate
is formatted yyyy/MM/dd
and xtime
is HH:mm:ss
. Then you could exclude .toString()
String
fields, you have to add an additional space: MaterialCodeCSV.xdate + ' ' + MaterialCodeCSV.xtime
yyyy-MM-dd HH:mm:ss
. In the second case you parse with yyyy/mm/dd H:mm:ss
. This reads "year/minute/day". Also there is only one hour digit, not allowing anything after 9:59:59 o'clock to be parsed. Correctly you should use yyyy/MM/dd HH:mm:ss
.그래서 다음과 같이한다 결론적으로 (내가 제대로 가정하면 당신은 올바른 형식 사용 String
에 대한 필드 xdate
와 xtime
)
MaterialCodeCSV.xdate == null ?
TalendDate.getCurrentDate() :
TalendDate.parseDateLocale("yyyy/MM/dd HH:mm:ss", MaterialCodeCSV.xdate + ' ' + MaterialCodeCSV.xtime,"EN");
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다