You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2019/05/24 13:41:31 UTC

[GitHub] [skywalking] flycash commented on a change in pull request #2713: Test server core query

flycash commented on a change in pull request #2713: Test server core query
URL: https://github.com/apache/skywalking/pull/2713#discussion_r287364365
 
 

 ##########
 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:
   Okay, I will revert it to master

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services