Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Current System Time

Tags:

How to get Current System's Time and Date without using Calender.getInstance()?

like image 270
Niranj Patel Avatar asked Feb 23 '11 10:02

Niranj Patel


People also ask

How can I get current system time?

To retrieve the current system date and time in local time, use the GetLocalTime function.

How do I get the current time in spring boot?

Here is the code. . . . public static void getCurrentTimeUsingCalendar() { Calendar cal = Calendar. getInstance(); Date date=cal. getTime(); DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); String formattedDate=dateFormat.

How can I get current time in Android?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. In the above code, we have given text view, it going to print the current date on the window manager.


1 Answers

Try this:

//-------- Don't know whether this will work on android or not. long dtMili = System.currentTimeMillis(); Date dt = new Date(dtMili); 

or

new Date().getTime() 
like image 158
Harry Joy Avatar answered Sep 20 '22 21:09

Harry Joy