Source Code : Convert longs (time_t in UNIX terminology) to seconds

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Convert longs (time_t in UNIX terminology) to seconds

       

/**
 * Convert longs (time_t in UNIX terminology) to seconds.
 */
public class LongToMSec {
  public static void main(String[] args) {
    System.out.println(msToSecs(1000));
    System.out.println(msToSecs(1100));
    System.out.println(msToSecs(1024));
  }

  /** Convert a long ("time_t") to seconds and milliseconds */
  public static String msToSecs(long t) {
    // The first attempt fails for the case "1024"
    //return t/1000 + "." + t%1000;

    return Double.toString(t / 1000D);
  }
}

           
         
    
    
    
    
    
    
  

Thank with us