@Test public void GetDescriptiveTimeString_9001Seconds_ReturnsCorrespondingHours(){ String actual = Strings.getDescriptiveDurationString(9001, GetDescriptiveTimeString_Context()); String expected = "2h 30m 1s"; assertThat("9001 seconds returns correspnding time", actual, is(expected)); }
public static String getDescriptiveDurationString(int numberOfSeconds, Context context) { String descriptive; int hours; int minutes; int seconds; int remainingSeconds; if(numberOfSeconds==0){ return ""; } if (numberOfSeconds == 1) { return context.getString(R.string.time_onesecond); } if (numberOfSeconds == 30) { return context.getString(R.string.time_halfminute); } if (numberOfSeconds == 60) { return context.getString(R.string.time_oneminute); } if (numberOfSeconds == 900) { return context.getString(R.string.time_quarterhour); } if (numberOfSeconds == 1800) { return context.getString(R.string.time_halfhour); } if (numberOfSeconds == 3600) { return context.getString(R.string.time_onehour); } if (numberOfSeconds == 4800) { return context.getString(R.string.time_oneandhalfhours); } if (numberOfSeconds == 9000) { return context.getString(R.string.time_twoandhalfhours); } hours = numberOfSeconds / 3600; remainingSeconds = numberOfSeconds % 3600; minutes = remainingSeconds / 60; seconds = remainingSeconds % 60; descriptive = String.format(context.getString(R.string.time_hms_format), String.valueOf(hours), String.valueOf(minutes), String.valueOf(seconds)); return descriptive; }
Strings { public static String getDescriptiveDurationString(int numberOfSeconds, Context context) { String descriptive; int hours; int minutes; int seconds; int remainingSeconds; if(numberOfSeconds==0){ return ""; } if (numberOfSeconds == 1) { return context.getString(R.string.time_onesecond); } if (numberOfSeconds == 30) { return context.getString(R.string.time_halfminute); } if (numberOfSeconds == 60) { return context.getString(R.string.time_oneminute); } if (numberOfSeconds == 900) { return context.getString(R.string.time_quarterhour); } if (numberOfSeconds == 1800) { return context.getString(R.string.time_halfhour); } if (numberOfSeconds == 3600) { return context.getString(R.string.time_onehour); } if (numberOfSeconds == 4800) { return context.getString(R.string.time_oneandhalfhours); } if (numberOfSeconds == 9000) { return context.getString(R.string.time_twoandhalfhours); } hours = numberOfSeconds / 3600; remainingSeconds = numberOfSeconds % 3600; minutes = remainingSeconds / 60; seconds = remainingSeconds % 60; descriptive = String.format(context.getString(R.string.time_hms_format), String.valueOf(hours), String.valueOf(minutes), String.valueOf(seconds)); return descriptive; } }
Strings { public static String getDescriptiveDurationString(int numberOfSeconds, Context context) { String descriptive; int hours; int minutes; int seconds; int remainingSeconds; if(numberOfSeconds==0){ return ""; } if (numberOfSeconds == 1) { return context.getString(R.string.time_onesecond); } if (numberOfSeconds == 30) { return context.getString(R.string.time_halfminute); } if (numberOfSeconds == 60) { return context.getString(R.string.time_oneminute); } if (numberOfSeconds == 900) { return context.getString(R.string.time_quarterhour); } if (numberOfSeconds == 1800) { return context.getString(R.string.time_halfhour); } if (numberOfSeconds == 3600) { return context.getString(R.string.time_onehour); } if (numberOfSeconds == 4800) { return context.getString(R.string.time_oneandhalfhours); } if (numberOfSeconds == 9000) { return context.getString(R.string.time_twoandhalfhours); } hours = numberOfSeconds / 3600; remainingSeconds = numberOfSeconds % 3600; minutes = remainingSeconds / 60; seconds = remainingSeconds % 60; descriptive = String.format(context.getString(R.string.time_hms_format), String.valueOf(hours), String.valueOf(minutes), String.valueOf(seconds)); return descriptive; }  }
Strings { public static String getDescriptiveDurationString(int numberOfSeconds, Context context) { String descriptive; int hours; int minutes; int seconds; int remainingSeconds; if(numberOfSeconds==0){ return ""; } if (numberOfSeconds == 1) { return context.getString(R.string.time_onesecond); } if (numberOfSeconds == 30) { return context.getString(R.string.time_halfminute); } if (numberOfSeconds == 60) { return context.getString(R.string.time_oneminute); } if (numberOfSeconds == 900) { return context.getString(R.string.time_quarterhour); } if (numberOfSeconds == 1800) { return context.getString(R.string.time_halfhour); } if (numberOfSeconds == 3600) { return context.getString(R.string.time_onehour); } if (numberOfSeconds == 4800) { return context.getString(R.string.time_oneandhalfhours); } if (numberOfSeconds == 9000) { return context.getString(R.string.time_twoandhalfhours); } hours = numberOfSeconds / 3600; remainingSeconds = numberOfSeconds % 3600; minutes = remainingSeconds / 60; seconds = remainingSeconds % 60; descriptive = String.format(context.getString(R.string.time_hms_format), String.valueOf(hours), String.valueOf(minutes), String.valueOf(seconds)); return descriptive; }  static String getDescriptiveDurationString(int numberOfSeconds,
                                                      Context context); static String getBearingDescription(float bearingDegrees,
                                               Context context); static String cleanDescriptionForXml(String desc); static String cleanDescriptionForJson(String desc); static String getIsoDateTime(Date dateToFormat); static String getIsoDateTimeFormat(); static String getIsoCalendarDate(Date dateToFormat); static String getIsoCalendarDateFormat(); static String getReadableDateTime(Date dateToFormat); static boolean isNullOrEmpty(String text); static String htmlDecode(String text); static String getBuildSerial(); static String getFormattedFileName(); static String getFormattedFileName(Session session, PreferenceHelper ph); static String getFormattedCustomFileName(String baseName, Calendar calendar, PreferenceHelper ph); static int toInt(String number, int defaultVal); static String getSpeedDisplay(Context context, double metersPerSecond, boolean imperial); static String getDistanceDisplay(Context context, double meters, boolean imperial, boolean autoscale); static String getTimeDisplay(Context context, long milliseconds); static Map<String, String> getAvailableLocales(Context context); static String getSanitizedMarkdownForFaqView(String md); static String getDegreesMinutesSeconds(double decimaldegrees, boolean isLatitude); static String getDegreesDecimalMinutes(double decimaldegrees, boolean isLatitude); static String getDecimalDegrees(double decimaldegrees); static String getFormattedLatitude(double decimaldegrees); static String getFormattedLongitude(double decimaldegrees); static String getDetectedActivityName(DetectedActivity detectedActivity); }
Strings { public static String getDescriptiveDurationString(int numberOfSeconds, Context context) { String descriptive; int hours; int minutes; int seconds; int remainingSeconds; if(numberOfSeconds==0){ return ""; } if (numberOfSeconds == 1) { return context.getString(R.string.time_onesecond); } if (numberOfSeconds == 30) { return context.getString(R.string.time_halfminute); } if (numberOfSeconds == 60) { return context.getString(R.string.time_oneminute); } if (numberOfSeconds == 900) { return context.getString(R.string.time_quarterhour); } if (numberOfSeconds == 1800) { return context.getString(R.string.time_halfhour); } if (numberOfSeconds == 3600) { return context.getString(R.string.time_onehour); } if (numberOfSeconds == 4800) { return context.getString(R.string.time_oneandhalfhours); } if (numberOfSeconds == 9000) { return context.getString(R.string.time_twoandhalfhours); } hours = numberOfSeconds / 3600; remainingSeconds = numberOfSeconds % 3600; minutes = remainingSeconds / 60; seconds = remainingSeconds % 60; descriptive = String.format(context.getString(R.string.time_hms_format), String.valueOf(hours), String.valueOf(minutes), String.valueOf(seconds)); return descriptive; }  static String getDescriptiveDurationString(int numberOfSeconds,
                                                      Context context); static String getBearingDescription(float bearingDegrees,
                                               Context context); static String cleanDescriptionForXml(String desc); static String cleanDescriptionForJson(String desc); static String getIsoDateTime(Date dateToFormat); static String getIsoDateTimeFormat(); static String getIsoCalendarDate(Date dateToFormat); static String getIsoCalendarDateFormat(); static String getReadableDateTime(Date dateToFormat); static boolean isNullOrEmpty(String text); static String htmlDecode(String text); static String getBuildSerial(); static String getFormattedFileName(); static String getFormattedFileName(Session session, PreferenceHelper ph); static String getFormattedCustomFileName(String baseName, Calendar calendar, PreferenceHelper ph); static int toInt(String number, int defaultVal); static String getSpeedDisplay(Context context, double metersPerSecond, boolean imperial); static String getDistanceDisplay(Context context, double meters, boolean imperial, boolean autoscale); static String getTimeDisplay(Context context, long milliseconds); static Map<String, String> getAvailableLocales(Context context); static String getSanitizedMarkdownForFaqView(String md); static String getDegreesMinutesSeconds(double decimaldegrees, boolean isLatitude); static String getDegreesDecimalMinutes(double decimaldegrees, boolean isLatitude); static String getDecimalDegrees(double decimaldegrees); static String getFormattedLatitude(double decimaldegrees); static String getFormattedLongitude(double decimaldegrees); static String getDetectedActivityName(DetectedActivity detectedActivity);  }