Skip to content Skip to sidebar Skip to footer

Hh: Mm In Range Bar

I use Ermodo Range Bar, and the fact that I need to display a minimum value and a maximum value in hours and minutes ... That is below: public class FilterActivity extends Activi

Solution 1:

Using DecimalFormat you can achieve.

DecimalFormat deciFormat= new DecimalFormat("00");
mDepartMin.setText(deciFormat.format(minHour) + ":" + deciFormat.format(minMinute));

OR Using Calendar

mDepartMin.setText(getFormattedDate(minHour,minMinute));

Call this below method

publicstatic String getFormattedDate(int hour, int minute) {
    Calendar cale = Calendar.getInstance();
    cale.set(Calendar.HOUR_OF_DAY, hour);
    cale.set(Calendar.MINUTE, minute);
    SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm");
    return dateFormat.format(cale.getTime());
}

Post a Comment for "Hh: Mm In Range Bar"