From 3e767805dbfa303c84495837ca580f61a63afb8f Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 25 Mar 2013 15:36:06 -0700 Subject: [PATCH] fix the failure of a few global unit tests. --- .../CustomPropertiesMapper.java | 25 ++++++++++--------- .../CustomPropertiesMapperTest.java | 16 ++++++------ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java index a12fbb4ee819..89e6fec612bc 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapper.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.serviceBus.implementation; @@ -19,6 +19,7 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; +import java.util.Locale; import java.util.TimeZone; public class CustomPropertiesMapper { @@ -53,14 +54,14 @@ else if (type == Boolean.class) { return value.toString(); } else if (Calendar.class.isAssignableFrom(type)) { - DateFormat format = new SimpleDateFormat(RFC_1123); + DateFormat format = new SimpleDateFormat(RFC_1123, Locale.US); Calendar calendar = (Calendar) value; format.setTimeZone(calendar.getTimeZone()); String formatted = format.format(calendar.getTime()); return "\"" + formatted + "\""; } else if (Date.class.isAssignableFrom(type)) { - DateFormat format = new SimpleDateFormat(RFC_1123); + DateFormat format = new SimpleDateFormat(RFC_1123, Locale.US); format.setTimeZone(TimeZone.getTimeZone("GMT")); String formatted = format.format((Date) value); return "\"" + formatted + "\""; @@ -78,7 +79,7 @@ public Object fromString(String value) throws ParseException { if (value.startsWith("\"") && value.endsWith("\"")) { String text = value.substring(1, value.length() - 1); if (isRFC1123(text)) { - SimpleDateFormat format = new SimpleDateFormat(RFC_1123); + SimpleDateFormat format = new SimpleDateFormat(RFC_1123, Locale.US); return format.parse(text); } @@ -103,7 +104,7 @@ private boolean isRFC1123(String text) { return false; } try { - SimpleDateFormat format = new SimpleDateFormat(RFC_1123); + SimpleDateFormat format = new SimpleDateFormat(RFC_1123, Locale.US); format.parse(text); return true; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java index 2ab3572c34db..323912b28277 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/serviceBus/implementation/CustomPropertiesMapperTest.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.serviceBus.implementation;