Java tutorial
import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.temporal.ChronoField; public class Main { public static void main(String[] args) { DateTimeFormatter formatter = new DateTimeFormatterBuilder().appendValue(ChronoField.HOUR_OF_DAY) .appendLiteral(":").appendValue(ChronoField.MINUTE_OF_HOUR).toFormatter(); System.out.println(formatter.format(LocalDateTime.now())); } }