Today i have written a program to convert seconds into hours, minutes and seconds in java.  Any one can easily understand this program and implement in their web application without any difficulties. Definitely it is more usefull for those who are working on date/time related functionalites. Lets start understanding the example carefully.
package Examples;

public class ConvertSeconds2Time {
 public static String getFormattedTimeString(long timeInSeconds) {
  String timeStr = new String();
  long sec_term = 1;
  long min_term = 60 * sec_term;
  long hour_term = 60 * min_term;
  long result = Math.abs(timeInSeconds);

  int hour = (int) (result / hour_term);
  result = result % hour_term;
  int min = (int) (result / min_term);
  result = result % min_term;
  int sec = (int) (result / sec_term);

  if (timeInSeconds < 0) {
   timeStr = "-";
  if (hour > 0) {
   timeStr += hour + "h ";
  if (min > 0) {
   timeStr += min + "m ";
  if (sec > 0) {
   timeStr += sec + "s ";
  return timeStr;
 public static void main(String args[]){



  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training in India . Nowadays Java has tons of job opportunities on various vertical industry.

  2. Cool you write, the information is very good and interesting, I'll give you a link to my site. 900 seconds into minutes

  3. I use basically superior fabrics : you will discover these products by: 900 seconds into minutes

  4. İnstagram takipçi satın al! İnstagram takipçi sitesi ile takipçi satın al sende sosyal medyada fenomen olmaya bir adım at. Sende hemen instagram takipçi satın almak istiyorsan tıkla:

    1- takipçi satın al

    2- takipçi satın al

    3- takipçi satın al