For Java.
Let's get some practice using Java libraries! Create a class named Formatter. Formatter should provide one public class method formatDate. It should accept a positive long representing milliseconds since 1970 and return a String containing the ISO-8601 representation of this time. Here is one example for a recent timestamp: given 1602106609897 your function should return 2020-10-07T21:36:49.897Z.
Do not overthink this. The solution we are after is a single line of code. We suggest that you explore the various built-in Java libraries for working with dates and times.
PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE, IF YOU
NEED ANY MODIFICATION THEN LET ME KNOW, I WILL DO IT FOR
YOU
import java.time.*;
import java.util.*;
class Formatter {
public static String formatDate(long l) {
return Instant.ofEpochMilli(l).toString();
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
long l = in.nextLong();
System.out.println(formatDate(l));
}
}
Get Answers For Free
Most questions answered within 1 hours.