File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
main/java/org/elasticsearch/river/ubb/settings
test/java/org/elasticsearch/river/ubb/settings Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change 11package org .elasticsearch .river .ubb .settings ;
22
3+ import java .text .DecimalFormat ;
34import java .util .regex .Pattern ;
45
56public class RiverUtils {
@@ -86,16 +87,18 @@ public static boolean isNullOrEmpty(CharSequence s) {
8687 public static String getTimeString (long timeInMilliSeconds ) {
8788 //Time in seconds
8889 double timeInSeconds = timeInMilliSeconds /1000.0 ;
90+ //Format to 2 decimal places
91+ DecimalFormat df = new DecimalFormat (".##" );
8992 //In minutes
9093 if (timeInSeconds >= 60 && timeInSeconds < 60 * 60 ) {
91- return timeInSeconds /60 + " min " ;
94+ return df . format ( timeInSeconds /60 ) + " minutes " ;
9295 }
9396 //In hours
9497 if (timeInSeconds >= 60 * 60 && timeInSeconds < 24 * 3600 ) {
95- return timeInSeconds /3600 + " hr " ;
98+ return df . format ( timeInSeconds /3600 ) + " hours " ;
9699 }
97100 //default unit
98- return timeInSeconds + " s " ;
101+ return df . format ( timeInSeconds ) + " seconds " ;
99102 }
100103
101104
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ public class EEASettingsTest {
1010 public void getTimeFormatAsString () {
1111 assertEquals ("1.0 seconds" , RiverUtils .getTimeString (1000 ));
1212 assertEquals ("1.0 minutes" , RiverUtils .getTimeString (60 *1000 ));
13+ assertEquals ("3.33 seconds" , RiverUtils .getTimeString (3333 ));
1314 }
1415
1516
You can’t perform that action at this time.
0 commit comments