cancel
Showing results for 
Search instead for 
Did you mean: 

How to use dateformat for java.sql.date

Former Member
0 Kudos

Hi All,

please help me in this,

in my application i am using one method which expecting java.sql.date value,

here u can see the code.

java.util.Date utilDate = new java.util.Date(); //current date

java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());// current date to sql date convertion

DateFormat sdDate = new SimpleDateFormat("yyyyMMdd");// i need date in this format

String docdat = sdDate.format(sqlDate);

in this method i cant pass directly docdat string value i need to pass sqlDate value.

wdContext.currentZib_File_Input_CustCntrlElement().set_Load_Date(here sqlDate value i shud pass);// this method is expecting java.sql.date

please help in this,

thanks in advance

sush

Accepted Solutions (0)

Answers (3)

Answers (3)

lokesh_kamana
Active Contributor
0 Kudos

Hi,

Are you formatting the date for your display purpose.

If it is for your display purpose then take a string attribute and display it.

And send the sqlDate to the backend.

But there is a problem here if the backend attribute is of type DATS and ur front end context attribute is of type date.

Then when ur pasing the date to the backend

Ex:-03/11/2009.

/ will also be considered and backend will only take upto 03/11/20.

Only will be taken. 08 will be left.

Since the length of DATS attribute is 8.

Thanks & Regards,

Lokesh.

Former Member
0 Kudos

Hi

Check the link , will help you

https://www.sdn.sap.com/irj/scn/forums

former_member191569
Active Participant
0 Kudos

Hello Sushma,

Your problem is that you need a java.sql.Date value to pass to your context attribute. Date formatting is helpful when you want to print a date. If your context attribute is a date (not a String), you do not have to deal with Date formatting. The type java.sql.Date knows nothing about date formatting (just and object representing a date) and this type is the type of the context attribute you have to feed. If you want to show date in the format "yyyyMMdd", you have to define you when you get the value from context attribute.

Hope it helps,

David