cancel
Showing results for 
Search instead for 
Did you mean: 

date format

Former Member
0 Kudos

Hi,

Need to send a date to back-end, when i make it a string it gives me the following format YYYY-MM-DD, but I want to pass it as a date type in the format DD.MM.YYYY how do I do that.

regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Eoin,

If back end is R/3 system, u can pass java.sql.Date as date which worked for me. No need of convering it to dd.mm.yyyy format.

For example, if u want to pass todays date, then pass

new java.sql.Date(System.currentTimeMillis())

Regards

Fahad Hamsa

Former Member
0 Kudos

Now I have this <code>

inputPS.setEffective_Date(wdContext.currentContextElement().getEffective_Date());

<code>

how should I adjust the code?

Former Member
0 Kudos

Hi ,

In properties of Effective_Date attribute, select the type as date (provided in dropdown). It is java.sql.Date by default.

Then pass this date variable as in ur code

Regards

Fahad Hamsa

Former Member
0 Kudos

still same issue

Former Member
0 Kudos

Hai,

Date d = wdContext.currentContextElement().getDate();

SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");

Date reqDate= sdf.format(d);

Regards,

Naga

null

Former Member
0 Kudos

Eoin,


/*1*/ SimpleDateFormat fmtIn = new SimpleDateFormat("yyyy-MM-dd");
/*2*/ Date date = fmtIn.parse("2007-03-14");
/*3*/ SimpleDateFormat fmtOut = new SimpleDateFormat("dd.MM.yyyy");
/*4*/ String out = fmtOut.format(date);

If type of wdContext.currentContextElement().getEffective_Date() is String then pass it instead of constant to /2/, if it is Date then start directly with line /3/ and comment out /1/ and /2/.

Finally call inputPS.setEffective_Date(out);

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Message was edited by:

Valery Silaev

Former Member
0 Kudos

Thanks, how do I convert the out string to a date type?

Date date = wdContext.currentContextElement().getEffective_Date();

SimpleDateFormat fmtOut = new SimpleDateFormat("dd.MM.yyyy");

String out = fmtOut.format(date);

inputPS.setEffective_Date(out);

Former Member
0 Kudos

Eoin,

Then the whole code is just no-op: you get date, convert it to string, then converts string back to the same date.

Please describe details of your task -- seems that we are solving wrong problem

VS

Former Member
0 Kudos

hai,

convert date to Strring

SimpleDateFormat sdf = new SimpleDateFormat

("dd.MM.yyyy", Locale.US);

Date d = sdf.parse(strdate);

regards,

naga

Former Member
0 Kudos

the effective date it's a single type with a date type.

The format now is going in is yyyy-MM-dd and the back-end only acceps date format dd.MM.yyyy so I want to change the format which is going into the bapi

Former Member
0 Kudos

Eoin,

You say that back-end accept string in certain format.

Then why it's necessary to convert correctly formatted string to date?

VS

Former Member
0 Kudos

the input parameter is type date

Former Member
0 Kudos

Hi Eoin,

You cant create a date object with format dd.MM.yyyy

In java, there are 2 date types

1. java.sql.Date . Its format is yyyy-MM-dd

2. java.util.Date . Its format is yyyy/MM/dd

So we can pass the date object to RFC only in the above two formats. Otherwise we can pass dd.MM.yyyy as a string to RFC or we can convert a string enterd by user in dd.MM.yyyy format to any of the above date formats and pass that date object.

I dont know why ur RFC is not accepting sql date because it worked perfectly for me and I think sql date will work for all RFCs.

What error u r getting while calling RFC ?

Regards

Fahad Hamsa

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Eoin,

You want to change the date format to YYYY-MM-DD.

This can be done by creating a variable of type java.sql.Date.

You must have a context of type 'date' binded to ur input field, just take the value of that context into a variable of java.sql.Date type as:

java.sql.Date Convert_date = wdContext.current<ur context node name>.get<Context attribute name>;

You can then use Convert_date.toString() function to display it.

Hope it Helps.

Regards,

Alka.

Former Member
0 Kudos

Hi Eoin,

Go through the following threads:

Regards,

Jhansi