FastDateFormat
문자열 "0759"및 "1401"을 구문 분석하려고하는데 ParsingException
이 표시됩니다.FastDateFormat 구문 분석 문제
괜찮 으면 SimpleDateFormat
으로 작동하지만 스레드 안전하지 않으므로 사용하지 않는 것이 좋습니다. 추가 작업을 수행하기 위해 현재 시간이 특정 시간 프레임 내에 있는지 확인하고 있습니다. 아래 코드 대신 FastDateFormat
을 사용하고 싶습니다. FastDateFormat.parse(String)
상태의
try{
SimpleDateFormat time_to_string = new SimpleDateFormat("HHmm");
String executionEndTime = time_to_string.format(stepExecution.getEndTime());
Date emailDeliveryStartTime =
(Date) time_to_string.parse("0759");
Date emailDeliveryEndTime =
(Date) time_to_string.parse("1401");
Date currentSystemTime = (Date) time_to_string.parse(executionEndTime);
Calendar calendar1 = Calendar.getInstance();
calendar1.setTime(emailDeliveryStartTime);
Calendar calendar2 = Calendar.getInstance();
calendar2.setTime(emailDeliveryEndTime);
Calendar calendar3 = Calendar.getInstance();
calendar3.setTime(currentSystemTime);
Date isEmailTime = calendar3.getTime();
if (isEmailTime.after(calendar1.getTime()) && isEmailTime.before(calendar2.getTime())) {
//return flowexecutionstatus
}
} catch (ParseException ex) {
//log message
}
는'stepExecution.getEndTime()'에 의해 반환되는 데이터 타입 무엇 :
나는 당신이 다음 사용하는 것이 좋습니다까요? – Blip
이것은 일괄 처리 작업입니다. 그래서 stepExecution은 일괄 처리 작업이 끝난 시간을 알려주는 getEndTime() 메소드를 가지고 있습니다. – user3505108
그렇다면 왜 시간을 문자열로 변환하고 다시 시간으로 변환합니까? – Blip