I'm using this to get current timestamp in seconds and add it to a string Double.toString((System.currentTimeMillis()/1000))
However instead of decimal notation I get "1.23213E9". How do I switch to the decimal notation ?
The shortest is
String secs = "" + System.currentTimeMillis() / 1000;
If you want to retain milli-seconds you can use
String secs = String.format("%.3f", System.currentTimeMillis() / 1000.0);
produces a String like
1342604140.503
Try this:
TimeUnit.MILLISECONDS.toSeconds(((System.currentTimeMillis());
String.valueOf(System.currentTimeMillis() / 1000)
that should do the trick? No need to convert it to a double
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With