cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert the date format from yyyy/mm/dd to dd/mm/yyyy

Former Member
0 Kudos

Hi all,

I have a table which is populated with the values from BAPI. The data for three fields like "Printdate", "Issue date" and "dateid" should be in the format dd/mm/yyyy.

I have not directly binded the table to the BAPI response parameters. Instead I have created a local value node and have binded the value attributes .

That means i have to write a logic to do so and then set the local value attribute accordingly.

Kindly help me to resolve the issue.

Regards

DK

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Hi DK,

Try this

String oldFormatData = "2006/07/17";
String newFormatData;

SimpleDateFormat old = new SimpleDateFormat("yyyy/MM/dd");
SimpleDateFormat new = new SimpleDateFormat("dd/MM/yyyy");
Date old = old.parse(oldFormatData);
newFormatData = new.format(old);

Best regards, Maksim Rashchynski.

Answers (2)

Answers (2)

sridhar_k2
Active Contributor
0 Kudos

Hi,

This below Date Convert function may help full you.

If you pass any String - Date to it, it will change the String to Desirable Date format. You can mention your date format as -> new SimpleDateFormat("yyyy/MM/dd");

public java.sql.Date stringToDate( java.lang.String dateAsString )

{

java.util.Date dateFrom = null;

java.sql.Date validFromDate = null;

try {

SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");

if (formatter != null && dateAsString != null) {

dateFrom = formatter.parse(dateAsString);

}

long dateFromAsLong = 0;

if (dateFrom != null) {

dateFromAsLong = dateFrom.getTime();

}

if (dateFromAsLong != 0) {

validFromDate = new java.sql.Date(dateFromAsLong);

}

return validFromDate;

}catch (Exception ex) {

manager.reportException(ex.getMessage(), true);

return validFromDate;

}

}

Regards,

Sridhar

Former Member
0 Kudos

Did you try using the WRITE statement.

WRITE date_var editmask dd/mm/yyyy to new_var.

Regards,

Ravi