Skip to content

Commit 691910f

Browse files
Fix #7 RFC3164 timestamp should use localtime instead of UTC
1 parent 5961111 commit 691910f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/main/java/com/cloudbees/syslog/SyslogMessage.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,18 @@ protected String newObject() {
6969
Locale.US,
7070
TimeZone.getTimeZone("GMT"),
7171
concurrency);
72+
73+
/**
74+
* According to <a href="http://tools.ietf.org/html/rfc3164#section-4.1.2">RFC31614- 4.1.2 HEADER Part of a syslog Packet</a>,
75+
* we should use local time and not GMT.
76+
* <quote>
77+
* The TIMESTAMP field is the local time and is in the format of "Mmm dd hh:mm:ss" (without the quote marks)
78+
* </quote>
79+
*/
7280
rfc3164DateFormat = new ConcurrentDateFormat(
7381
"MMM dd HH:mm:ss",
7482
Locale.US,
75-
TimeZone.getTimeZone("GMT"),
83+
TimeZone.getDefault(),
7684
concurrency);
7785
}
7886

src/test/java/com/cloudbees/syslog/SyslogMessageTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void testRfc5424Format() throws Exception {
6060
public void testRfc3164Format() throws Exception {
6161

6262
Calendar cal = Calendar.getInstance();
63-
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
63+
cal.setTimeZone(TimeZone.getDefault());
6464
cal.set(2013, Calendar.DECEMBER, 5, 10, 30, 5);
6565
cal.set(Calendar.MILLISECOND, 0);
6666

0 commit comments

Comments
 (0)