Skip to content

Commit

Permalink
Fix #7 RFC3164 timestamp should use localtime instead of UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrille-leclerc committed May 29, 2015
1 parent 5961111 commit 691910f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/main/java/com/cloudbees/syslog/SyslogMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,18 @@ protected String newObject() {
Locale.US,
TimeZone.getTimeZone("GMT"),
concurrency);

/**
* 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>,
* we should use local time and not GMT.
* <quote>
* The TIMESTAMP field is the local time and is in the format of "Mmm dd hh:mm:ss" (without the quote marks)
* </quote>
*/
rfc3164DateFormat = new ConcurrentDateFormat(
"MMM dd HH:mm:ss",
Locale.US,
TimeZone.getTimeZone("GMT"),
TimeZone.getDefault(),
concurrency);
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/cloudbees/syslog/SyslogMessageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void testRfc5424Format() throws Exception {
public void testRfc3164Format() throws Exception {

Calendar cal = Calendar.getInstance();
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
cal.setTimeZone(TimeZone.getDefault());
cal.set(2013, Calendar.DECEMBER, 5, 10, 30, 5);
cal.set(Calendar.MILLISECOND, 0);

Expand Down

0 comments on commit 691910f

Please sign in to comment.