DaanHoogland commented on code in PR #7032:
URL: https://github.com/apache/cloudstack/pull/7032#discussion_r1058797856
##########
server/src/main/java/com/cloud/api/dispatch/ParamProcessWorker.java:
##########
@@ -335,13 +337,20 @@ private void setFieldValue(final Field field, final
BaseCmd cmdObj, final Object
case DATE:
// This piece of code is for maintaining backward compatibility
// and support both the date formats(Bug 9724)
- final boolean isObjInNewDateFormat =
isObjInNewDateFormat(paramObj.toString());
- if (isObjInNewDateFormat) {
+ try {
+ field.set(cmdObj,
DateUtil.parseTZDateString(paramObj.toString()));
+ break;
+ } catch (ParseException parseException) {
+ s_logger.debug(String.format("Could not parse date [%s]
with timezone parser, trying to parse without timezone.", paramObj));
+ }
Review Comment:
Can you put this, or even the full case DATE block in a separate method,
please_
##########
server/src/main/java/com/cloud/api/dispatch/ParamProcessWorker.java:
##########
@@ -63,8 +63,10 @@
public class ParamProcessWorker implements DispatchWorker {
private static final Logger s_logger =
Logger.getLogger(ParamProcessWorker.class.getName());
- public final DateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd");
- public final DateFormat newInputFormat = new SimpleDateFormat("yyyy-MM-dd
HH:mm:ss");
+ private final String inputFormatString = "yyyy-MM-dd";
+ private final String newInputFormatString = "yyyy-MM-dd HH:mm:ss";
+ public final DateFormat inputFormat = new
SimpleDateFormat(inputFormatString);
+ public final DateFormat newInputFormat = new
SimpleDateFormat(newInputFormatString);
Review Comment:
```suggestion
private final static String inputFormatString = "yyyy-MM-dd";
private final static String newInputFormatString = "yyyy-MM-dd HH:mm:ss";
public final static DateFormat inputFormat = new
SimpleDateFormat(inputFormatString);
public final static DateFormat newInputFormat = new
SimpleDateFormat(newInputFormatString);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]