code: public static String formatTimeSec(long time) {
  
          StringBuffer str = new StringBuffer();
  
          if (time < 60) {
              str.append(time + " sec");
              return str.toString();
          }
  
          int days = (int) time / 86400;
  
          if (days != 0) {
              str.append(days + " days");
              time -= days * 86400;
          }
  
          int hours = (int) time / 3600;
  
          if (hours != 0) {
              if (str.length() != 0) str.append(", ");
              str.append(hours + " h");
              time -= hours * 3600;
          }
  
          int mins  = (int) time / 60;
  
          if (mins != 0) {
              if (str.length() != 0) str.append(", ");
              str.append(mins + " min");
              time -= mins * 60;
          }
  
          int sec   = (int) time;
  
          if (sec != 0) {
              if (str.length() != 0) str.append(", ");
              str.append(sec + " sec");
          }
  
          return str.toString();
      }
docs: Generates string representation of given time specified
  as long. The format is: [days][,][h][,][min][,][sec]