Skip to Content
avatar image
Former Member

How to do Right Justified in the mappin

Hi friends,

Can you help me to do the right justified for example 39.56- this should right side not from left. this field length is 11. infront of this 39.56 should be blank spaceses paded. how to do this

please help me

Thanks

ramidi

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Aug 01, 2007 at 04:52 AM

    Ramidi,

    Create simple UDF. Let say my input parameter name is "abc" . Write the below code in it

    StringBuffer pad= new StringBuffer();

    String ret_string="";

    int add=0;

    int trunc=0;

    if(abc.length()<=11)

    {

    add =11-abc.length();

    }

    if(abc.length()>11)

    {

    ret_string =abc.substring(0,11);

    }

    else

    {

    for(int i=0;i<add;i++)

    {

    pad.append(" ");

    }

    ret_string = pad.toString()""abc;

    }

    return""ret_string"";

    Hope it helps!!!

    Best regards,

    raj.

    Add comment
    10|10000 characters needed characters exceeded