Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion quickfixj-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
<version>2.1.5</version>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import quickfix.SystemTime;

import java.text.DateFormat;
import java.time.DateTimeException;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
Expand Down Expand Up @@ -135,26 +135,37 @@ public static Date convert(String value) throws FieldConvertError {
*/
public static LocalDateTime convertToLocalDateTime(String value) throws FieldConvertError {
verifyFormat(value);
int length = value.length();
try {
switch (length) {
case LENGTH_INCL_SECONDS:
return LocalDateTime.parse(value, FORMATTER_SECONDS);
case LENGTH_INCL_MILLIS:
return LocalDateTime.parse(value, FORMATTER_MILLIS);
case LENGTH_INCL_MICROS:
return LocalDateTime.parse(value, FORMATTER_MICROS);
case LENGTH_INCL_NANOS:
case LENGTH_INCL_PICOS:
return LocalDateTime.parse(value.substring(0, LENGTH_INCL_NANOS), FORMATTER_NANOS);
default:
throwFieldConvertError(value, TYPE);
int length = value.length();
int ns = 0;
if (length >= LENGTH_INCL_NANOS) {
ns = parseInt(value, 18, 9);
} else if (length == LENGTH_INCL_MICROS) {
ns = parseInt(value, 18, 6) * 1000;
} else if (length == LENGTH_INCL_MILLIS) {
ns = parseInt(value, 18, 3) * 1000000;
}
} catch (DateTimeParseException e) {

int yy = parseInt(value, 0, 4);
int mm = parseInt(value, 4, 2);
int dd = parseInt(value, 6, 2);
int h = parseInt(value, 9, 2);
int m = parseInt(value, 12, 2);
int s = parseInt(value, 15, 2);
return LocalDateTime.of(yy, mm, dd, h, m, s, ns);
} catch (DateTimeException e) {
throwFieldConvertError(value, TYPE);
}
return null;
}
}

private static int parseInt(String value, int off, int len) {
int num = 0;
for (int index = 0; index < len; index++) {
num = (num * 10) + value.charAt(off + index) - '0';
}
return num;
}

private static Long getMillisForDay(String value) {
// Performance optimization: the calendar for the start of the day is cached.
Expand Down