wu-sheng commented on a change in pull request #2713: Test server core query
URL: https://github.com/apache/skywalking/pull/2713#discussion_r287363061
 
 

 ##########
 File path: 
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/DurationUtils.java
 ##########
 @@ -81,33 +81,25 @@ public long endTimeDurationToSecondTimeBucket(Step step, 
String dateStr) {
     }
 
     public long startTimeToTimestamp(Step step, String dateStr) throws 
ParseException {
-        switch (step) {
-            case MONTH:
-                return new 
SimpleDateFormat("yyyy-MM").parse(dateStr).getTime();
-            case DAY:
-                return new 
SimpleDateFormat("yyyy-MM-dd").parse(dateStr).getTime();
-            case HOUR:
-                return new SimpleDateFormat("yyyy-MM-dd 
HH").parse(dateStr).getTime();
-            case MINUTE:
-                return new SimpleDateFormat("yyyy-MM-dd 
HHmm").parse(dateStr).getTime();
-            case SECOND:
-                return new SimpleDateFormat("yyyy-MM-dd 
HHmmss").parse(dateStr).getTime();
-        }
-        throw new UnexpectedException("Unsupported step " + step.name());
+        return dateStrToTimeStamp(step, dateStr, 0);
     }
 
     public long endTimeToTimestamp(Step step, String dateStr) throws 
ParseException {
+        return dateStrToTimeStamp(step, dateStr, 1);
+    }
+
+    private long dateStrToTimeStamp(Step step, String dateStr, int plus) 
throws ParseException {
         switch (step) {
             case MONTH:
-                return new DateTime(new 
SimpleDateFormat("yyyy-MM").parse(dateStr)).plusMonths(1).getMillis();
+                return new DateTime(new 
SimpleDateFormat("yyyy-MM").parse(dateStr)).plusMonths(plus).getMillis();
 
 Review comment:
   `plus 0` looks like strange. And codes are unclear.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to