This Java program demonstrates how to get the current UTC time in hours, minutes, and seconds using the Date, DateFormat, LocalTime, and SimpleDateFormat classes.
Overall, this program provides a simple example of how to get the current UTC time in hours, minutes, and seconds using the Date, DateFormat, LocalTime, and SimpleDateFormat classes in Java. However, it is worth noting that the Date and DateFormat classes have been replaced by the newer java.time API in Java 8 and later versions, which provides more flexible and robust date and time handling capabilities.
import java.util.*; import java.time.*; import java.text.*; public class Individual_Component { public static void main(String[] args) { Date dt = new Date(); DateFormat dtFormat = new SimpleDateFormat("hh:mm:ss"); final String str_dt = dtFormat.format(dt); LocalTime time = LocalTime.parse(str_dt); int h = time.getHour(); int m = time.getMinute(); int s = time.getSecond(); System.out.printf("Current Utc Time : %02d:%02d:%02d", h, m, s); } }
Current Utc Time : 02:20:31
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions