I need to get the current date without using any packages or any construction methods. Simply, i want to get the current date by convert date to string. I used this code. Please find the below code...

String getDate = new SimpleDateFormat("yyy/MM/dd HH:mm:ss");
        return getDate.format(date);

But, i'm getting these below errors

Error(s) detected while generating java. Compiler reported: ----------
1. ERROR in file://runtime:/PRGenJava/com/pegarules/generated/test_etax_contract_etaxlibrary.java (at line 10437)
	String getDate = new SimpleDateFormat("yyy/MM/dd HH:mm:ss");
SimpleDateFormat cannot be resolved to a type
1 problem (1 error)

Please Help on this.

Because a SimpleDateFormat is a SimpleDateFormat not a String.

new Date() will give you the current Date. and SimpleDateFormat's format method will allow you to format a String representation of that Date in any format you want.

Now, armed with that info and the API docs try it again.

Hi all,
I got that code any way. That is

java.util.Date date = new Date();

It gives the format of july,16,2010.
Thanks all.......

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.