-
Enhancement
-
Resolution: Unresolved
-
P4
-
8u66, 9
-
generic
-
windows_xp
A DESCRIPTION OF THE REQUEST :
When parse large text file using method a, performance is bad!
And the workaround code method b is not elegant.
private LocalDateTime a(String time) {
return LocalDateTime.parse(time, ofPattern("yyyyMMddHHmmss"));
}
// workaround code
private LocalDateTime b(String time) {
int year = Integer.valueOf(time.substring(0, 4));
int month = Integer.valueOf(time.substring(4, 6));
int day = Integer.valueOf(time.substring(6, 8));
int hour = Integer.valueOf(time.substring(8, 10));
int minute = Integer.valueOf(time.substring(10, 12));
int sec = Integer.valueOf(time.substring(12));
return LocalDateTime.of(year, month, day, hour, minute, sec);
}
JUSTIFICATION :
Performance is important !
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
improved performance
ACTUAL -
bad performance
CUSTOMER SUBMITTED WORKAROUND :
private LocalDateTime b(String time) {
int year = Integer.valueOf(time.substring(0, 4));
int month = Integer.valueOf(time.substring(4, 6));
int day = Integer.valueOf(time.substring(6, 8));
int hour = Integer.valueOf(time.substring(8, 10));
int minute = Integer.valueOf(time.substring(10, 12));
int sec = Integer.valueOf(time.substring(12));
return LocalDateTime.of(year, month, day, hour, minute, sec);
}
When parse large text file using method a, performance is bad!
And the workaround code method b is not elegant.
private LocalDateTime a(String time) {
return LocalDateTime.parse(time, ofPattern("yyyyMMddHHmmss"));
}
// workaround code
private LocalDateTime b(String time) {
int year = Integer.valueOf(time.substring(0, 4));
int month = Integer.valueOf(time.substring(4, 6));
int day = Integer.valueOf(time.substring(6, 8));
int hour = Integer.valueOf(time.substring(8, 10));
int minute = Integer.valueOf(time.substring(10, 12));
int sec = Integer.valueOf(time.substring(12));
return LocalDateTime.of(year, month, day, hour, minute, sec);
}
JUSTIFICATION :
Performance is important !
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
improved performance
ACTUAL -
bad performance
CUSTOMER SUBMITTED WORKAROUND :
private LocalDateTime b(String time) {
int year = Integer.valueOf(time.substring(0, 4));
int month = Integer.valueOf(time.substring(4, 6));
int day = Integer.valueOf(time.substring(6, 8));
int hour = Integer.valueOf(time.substring(8, 10));
int minute = Integer.valueOf(time.substring(10, 12));
int sec = Integer.valueOf(time.substring(12));
return LocalDateTime.of(year, month, day, hour, minute, sec);
}