Java tutorial
import java.time.LocalTime; public class Main { public static void main(String[] args) { System.out.println(getTime()); } public static String getTime() { return String.format("[%s:%s:%s]", zeroOne(LocalTime.now().getHour()), zeroOne(LocalTime.now().getMinute()), zeroOne(LocalTime.now().getSecond())); } public static String zeroOne(int second) { if (second < 10) { return "0" + second; } return String.valueOf(second); } }