Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 40952200C10 for ; Fri, 3 Feb 2017 19:27:07 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 3F314160B43; Fri, 3 Feb 2017 18:27:07 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8A16D160B3F for ; Fri, 3 Feb 2017 19:27:06 +0100 (CET) Received: (qmail 2367 invoked by uid 500); 3 Feb 2017 18:27:05 -0000 Mailing-List: contact dev-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list dev@drill.apache.org Received: (qmail 2351 invoked by uid 99); 3 Feb 2017 18:27:05 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Feb 2017 18:27:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 51605DFC40; Fri, 3 Feb 2017 18:27:05 +0000 (UTC) From: kkhatua To: dev@drill.apache.org Reply-To: dev@drill.apache.org References: In-Reply-To: Subject: [GitHub] drill pull request #739: DRILL-5230: Translation of millisecond duration int... Content-Type: text/plain Message-Id: <20170203182705.51605DFC40@git1-us-west.apache.org> Date: Fri, 3 Feb 2017 18:27:05 +0000 (UTC) archived-at: Fri, 03 Feb 2017 18:27:07 -0000 Github user kkhatua commented on a diff in the pull request: https://github.com/apache/drill/pull/739#discussion_r99393776 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/TableBuilder.java --- @@ -56,6 +47,30 @@ public TableBuilder(final String[] columns) { sb.append("\n"); } + /** + * Representation of a millisecond duration in a short readable text + * @param millis Duration in milliseconds + * @return Human-Readable Duration Time + */ + public String shortDurationFormat(long millis) { + long days = TimeUnit.MILLISECONDS.toDays(millis); + long hours = TimeUnit.MILLISECONDS.toHours(millis) - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(millis)); + long minutes = TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)); + long seconds = TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)); + long milliSeconds = millis - TimeUnit.SECONDS.toMillis(TimeUnit.MILLISECONDS.toSeconds(millis)); + String formattedDuration = ""; + if (days >= 1) { + formattedDuration = days + "d" + hours + "h" + minutes + "m"; + } else if (hours >= 1) { + formattedDuration = hours + "h" + minutes + "m"; + } else if (minutes >= 1) { + formattedDuration = minutes + "m" + seconds + "s"; + } else { + formattedDuration = seconds + "." + milliSeconds + "s"; --- End diff -- Good catch. I'll update the test case as well and apply the String.format() --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---