Skip to Content
author's profile photo
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    Jul 17, 2006 at 05:31 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Jul 18, 2006 at 06:13 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Jul 17, 2006 at 05:35 PM

    Did you try using the WRITE statement.

    WRITE date_var editmask dd/mm/yyyy to new_var.

    Regards,

    Ravi

    Add comment
    10|10000 characters needed characters exceeded