Skip to content

Bump slf4j.version from 1.7.36 to 2.0.0 #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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 pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<jdkLevel>1.8</jdkLevel>
<slf4j.version>1.7.36</slf4j.version>
<slf4j.version>2.0.0</slf4j.version>
<junit.version>4.13.2</junit.version>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
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,41 @@ 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);
if (s == 60) {
// leap second
s = 59;
}
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