File tree Expand file tree Collapse file tree 3 files changed +19
-7
lines changed
main/java/com/spectralogic/ds3client
test/java/com/spectralogic/ds3client/utils Expand file tree Collapse file tree 3 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -271,7 +271,7 @@ private String buildPath() {
271271
272272 private void addHeaders (final HttpRequest httpRequest ) {
273273 // Add common headers.
274- final String date = DateFormatter .dateToRfc882 ();
274+ final String date = DateFormatter .dateToRfc822 ();
275275 httpRequest .addHeader (HOST , NetUtils .buildHostField (NetworkClientImpl .this .connectionDetails ));
276276 httpRequest .addHeader (DATE , date );
277277 httpRequest .addHeader (CONTENT_TYPE , this .ds3Request .getContentType ());
Original file line number Diff line number Diff line change 1717
1818import java .text .SimpleDateFormat ;
1919import java .util .Date ;
20+ import java .util .Locale ;
2021import java .util .TimeZone ;
2122
2223public final class DateFormatter {
2324 final static private String RFC822FORMAT = "EEE, dd MMM yyyy HH:mm:ss Z" ;
2425 /**
25- * Returns a RFC-882 formatted string with the current time.
26+ * Returns a RFC-822 formatted string with the current time.
2627 */
27- public static String dateToRfc882 () {
28- return dateToRfc882 (new Date ());
28+ public static String dateToRfc822 () {
29+ return dateToRfc822 (new Date ());
2930 }
3031
31- public static String dateToRfc882 (final Date date ) {
32- final SimpleDateFormat sdf = new SimpleDateFormat (RFC822FORMAT );
32+ public static String dateToRfc822 (final Date date ) {
33+ final SimpleDateFormat sdf = new SimpleDateFormat (RFC822FORMAT , Locale . US );
3334 sdf .setTimeZone (TimeZone .getTimeZone ("GMT" ));
3435 return sdf .format (date );
3536 }
Original file line number Diff line number Diff line change 1919import org .junit .Test ;
2020
2121import java .util .Date ;
22+ import java .util .Locale ;
2223
2324import static org .hamcrest .CoreMatchers .is ;
2425import static org .hamcrest .MatcherAssert .assertThat ;
@@ -29,6 +30,16 @@ public class DateFormatter_Test {
2930 public void formatDate () {
3031 final Date date = new Date (1390414308132L );
3132
32- assertThat (DateFormatter .dateToRfc882 (date ), is ("Wed, 22 Jan 2014 18:11:48 +0000" ));
33+ assertThat (DateFormatter .dateToRfc822 (date ), is ("Wed, 22 Jan 2014 18:11:48 +0000" ));
34+ }
35+
36+ @ Test
37+ public void formatDateMandarin () {
38+ final Locale defaultLocale = Locale .getDefault ();
39+ Locale .setDefault (Locale .CHINESE );
40+ final Date date = new Date (1390414308132L );
41+
42+ assertThat (DateFormatter .dateToRfc822 (date ), is ("Wed, 22 Jan 2014 18:11:48 +0000" ));
43+ Locale .setDefault (defaultLocale );
3344 }
3445}
You can’t perform that action at this time.
0 commit comments