Skip to content

Commit e0cc971

Browse files
author
Yoan Blanc
committed
dateutil: constistency of tzdate input and output
Signed-off-by: Yoan Blanc <yoan.blanc@exoscale.ch>
1 parent 4d7a9d8 commit e0cc971

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

utils/src/main/java/com/cloud/utils/DateUtil.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@ public static Date currentGMTTime() {
3838
return new Date();
3939
}
4040

41-
// yyyy-MM-ddTHH:mm:ssZxxxx
41+
// yyyy-MM-ddTHH:mm:ssZZZZ or yyyy-MM-ddTHH:mm:ssZxxxx
4242
public static Date parseTZDateString(String str) throws ParseException {
43-
DateFormat dfParse = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'Z");
44-
return dfParse.parse(str);
43+
try {
44+
return s_outputFormat.parse(str);
45+
} catch (ParseException e) {
46+
DateFormat dfParse = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'Z");
47+
return dfParse.parse(str);
48+
}
4549
}
4650

4751
public static Date parseDateString(TimeZone tz, String dateString) {

0 commit comments

Comments
 (0)