This Java program demonstrates how to get the midnight time of the current day using the Calendar class.
Overall, the program retrieves the current date and time and sets the time to midnight, effectively extracting the midnight time of the current day.
import java.util.*; class Midnight_Time { public static void main(String[] args) { Calendar cal = new GregorianCalendar(); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); System.out.println(cal.getTime()); } }
Sat Nov 05 00:00:00 IST 2022
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions