+ 4
How to make clock
can we make a program by which we can see current time in JAVA or C++
4 Answers
+ 6
public class Program
{
import java.util.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; public class GettingCurrentDate { public static void main(String[] args) {
//getting current date and time using Date class
DateFormat df = new SimpleDateFormat("dd/MM/yy HH:mm:ss"); Date dateobj = new Date(); System.out.println(df.format(dateobj));
/*getting current date time using calendar class * An Alternative of above*/
Calendar calobj = Calendar.getInstance(); System.out.println(df.format(calobj.getTime())); } }
}
+ 3
import java.util.Date; public class DateDemo { public static void main(String args[]) { // Instantiate a Date object Date date = new Date(); // display time and date using toString() System.out.println(date.toString()); } }
+ 2
can you send me the program that I can run and see . in play ground.
+ 1
if u want the seconds of the time to be counting. how will u write the code