How to get Current date from computer in java

sandesh17's Avatar, Join Date: Jun 2013
Newbie Member
How to get current in java? Not from system's date because anyone can change it....
I want current to validate my application expiry...please help me...thanx in advance...
Exquisite's Avatar, Join Date: Aug 2011
Light Poster
Are you on javascript or java
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Originally Posted by Exquisite View Post
Are you on javascript or java
Why do you think this is in JS?
Exquisite like this
sparticus's Avatar
Unless you query an external time server, you will never know whether the given system time is accurate. This would require an internet connection however. I don't honestly think someone will change their system clock, which in turn will screw up a lot of other applications, to simply circumvent your application expiry logic.
ArnavKumar's Avatar, Join Date: Oct 2013
Newbie Member
You can use your database for this purpose. In this case your database will say your program what date is to pick and if you want to make some change it will be done in the database neither in the system nor in the program.
alia123's Avatar, Join Date: Jan 2016
Hey, here’s the code I’m sharing to get in the date and time just check this :

import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class GetCurrentDateTime {
  public static void main(String[] args) {

       DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
       //get current date time with Date()
       Date date = new Date();