-
-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathConcurrentRfc3164DateFormatTest.java
More file actions
47 lines (34 loc) · 1.51 KB
/
ConcurrentRfc3164DateFormatTest.java
File metadata and controls
47 lines (34 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.cloudbees.syslog.util;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
public class ConcurrentRfc3164DateFormatTest {
@Test
public void test_format_date_with_single_digit_day_of_month(){
TimeZone timeZone = TimeZone.getTimeZone("UTC");
Calendar cal = Calendar.getInstance();
cal.setTimeZone(timeZone);
cal.set(2013, Calendar.AUGUST, 7, 10, 30, 5);
cal.set(Calendar.MILLISECOND, 0);
Date singleDigitDayOfMonthDate = cal.getTime();
ConcurrentRfc3164DateFormat rfc3164DateFormat = new ConcurrentRfc3164DateFormat(Locale.US, timeZone, 50);
String actual = rfc3164DateFormat.format(singleDigitDayOfMonthDate);
Assert.assertThat(actual, Matchers.is("Aug 7 10:30:05"));
}
@Test
public void test_format_date_with_double_digit_day_of_month(){
TimeZone timeZone = TimeZone.getTimeZone("UTC");
Calendar cal = Calendar.getInstance();
cal.setTimeZone(timeZone);
cal.set(2013, Calendar.AUGUST, 17, 10, 30, 5);
cal.set(Calendar.MILLISECOND, 0);
Date singleDigitDayOfMonthDate = cal.getTime();
ConcurrentRfc3164DateFormat rfc3164DateFormat = new ConcurrentRfc3164DateFormat(Locale.US, timeZone, 50);
String actual = rfc3164DateFormat.format(singleDigitDayOfMonthDate);
Assert.assertThat(actual, Matchers.is("Aug 17 10:30:05"));
}
}