Try to fix test failing due to timezones.

This commit is contained in:
Mark Nellemann 2020-09-23 08:19:24 +02:00
parent 688cbf12a3
commit 7a019c5c18
3 changed files with 2 additions and 6 deletions

View File

@ -4,8 +4,6 @@ Basic syslog server written in Java. All received messages are written to *stdou
The syslog server is able to listen on UDP and/or TCP and parses syslog messages in either RFC5424 or RFC3164 (BSD) format. The default syslog port (514) requires you to run syslogd as root / administrator. If you do not with to do so, you can choose a port number (with the -p flag) above 1024.
*This project is in no way associated with, supported or endorsed by, International Business Machines Corporation (IBM).*
## Usage Instructions
- Install the syslogd package (*.deb* or *.rpm*) from [downloads](https://bitbucket.org/mnellemann/syslogd/downloads/) or compile from source.

View File

@ -137,9 +137,7 @@ public class SyslogParser {
// Date: Mmm dd hh:mm:ss
Instant instant = null;
try {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy MMM dd HH:mm:ss")
.withLocale(Locale.getDefault())
.withZone(ZoneId.systemDefault());
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy MMM dd HH:mm:ss").withZone(ZoneOffset.UTC);
instant = Instant.from(dateTimeFormatter.parse(odt.getYear() + " " + dateString));
} catch(DateTimeParseException e) {
log.error("parseDate()", e);

View File

@ -10,7 +10,7 @@ class SyslogParserTest extends Specification {
setup:
OffsetDateTime odt = OffsetDateTime.now()
String dateString = "Sep 12 22:50:13"
String dateString = "Sep 12 20:50:13"
when:
Instant inst = SyslogParser.parseRfc3164Timestamp(dateString)