I am using this to get the current time :
java.util.Calendar cal = java.util.Calendar.getInstance();
System.out.println(new java.text.SimpleDateFormat("EEEE, dd/MM/yyyy/hh:mm:ss")
.format(cal.getTime()));
I want to put the value (which I print it) into a date object, I tried this:
Date currentDate = new Date(value);
but eclipse tells me that this function is not good.
Edit
the value
is the value that I printed to you using system.out.println
Try this :-
Output:-
Your value should be proper format.
In your question also you have asked for this below :-
This style of date constructor is already deprecated.So, its no more use.Being we know that Date has 6 constructor.Read more
Use SimpleDateFormat parse method:
Since we have Java 8 with LocalDate I would suggest use next:
Above is the import method, below is the simple code for Date