Snip2Code is shutting down.
It has been quite a ride, since 2013 when we launched our first prototype: thanks to the effort of you guys we collected more than 3 million snippets!
We are very proud to help all our users to be more efficient in their jobs, and to be the central point to share programming knowledge for everyone.
Our basic service is free, so we always survived on our own resources to give you Snip2Code.
Unfortunately, we are no more in the financial position to sustain this effort, and therefore we are announcing here our permanent shut down,
which will take place on August 1st, 2020.
Please save your private snippets using our backup function in the settings, here.
This will allow us to pay for the servers and the infrastructure. If you want to donate, Contact Us!
6,010 13

Convert Milliseconds to Time hours, minutes and seconds as String.

Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
public class Main { public static void main(String[] args) { long totalTimeInMils=6003000; convertMillisToTime(totalTimeInMils); //Covert from Dates String strStartDate = "2018/08/16 17:10:00"; String strEndDate = "2018/08/16 17:20:01"; SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Date date = sdf.parse(strStartDate); Date endDate = sdf.parse(strEndDate); long millis = (endDate.getTime()- date.getTime()); convertMillisToTime(millis); } public static String convertMillisToTime(long Millis){ String convert = String.format("Total Time Taken: %d hour(s), %d minute(s), and %d second(s)", Millis/(1000*60*60), (Millis%(1000*60*60))/(1000*60), ((Millis%(1000*60*60))%(1000*60))/1000); System.out.println(convert); return convert; } }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus