Last active
July 15, 2020 20:43
-
-
Save austintraver/d2ecb2d04e451e54128b67fcfa42ccb6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.LocalTime; | |
import java.time.format.DateTimeFormatter; | |
public class Timer { | |
public static void main(String[] args) { | |
/* Get the current time */ | |
LocalTime localTime = LocalTime.now(); | |
/* Specify the formatting for the timestamp string */ | |
/* Read this Java documentation link to understand! */ | |
/* https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html */ | |
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss.SS"); | |
/* Generate the formatted timestamp string */ | |
String timestamp = String.format("[%s]", dateTimeFormatter.format(localTime)); | |
/* Print the formatted timestamp string */ | |
System.out.println(timestamp); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment