cancel
Showing results for 
Search instead for 
Did you mean: 

Date format

Former Member
0 Kudos

hi

explain code to check date format in webdynpro java.for ex default date format is mon/date/year(07/20/2007). when user enters date how to check its in valid format.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

HI,

PLEASE CHECK OUT THE BELOW PROGRAMS IT WILL HELP YOU

You can read user profile using table USR01.

You can format the date according to the user profile.

THis is an example. In your method, write ABAP code to retrive user profile.

FORM CONVERT-DATE.

SELECT SINGLE * FROM USR01 WHERE BNAME = SY-UNAME.

CASE USR01-DATFM.

WHEN '1' OR '2' OR '3'. "JJ.MM.AAAA

WA_JJ = SY-DATUM(2).

WA_MM = SY-DATUM+2(2).

WA_AAAA = SY-DATUM+4(4).

WHEN '4' OR '5' OR '6'. " AAAA.MM.JJ

WA_JJ = SY-DATUM+6(2).

WA_MM = SY-DATUM+4(2).

WA_AAAA = SY-DATUM(4).

ENDCASE.

ENDFORM.

-


DATA: ZTEMP(9).

CLEAR: ZTEMP, ZDD, ZMMM, ZYYYY.

CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'

EXPORTING

INPUT = IS_DLV_DELNOTE-HD_GEN-CREA_DATE

IMPORTING

OUTPUT = ZTEMP.

ZDD = ZTEMP+3(2).

ZMMM = ZTEMP+0(3).

ZYYYY = ZTEMP+5(4).

-


Suppose a date is given in the format 20050428 how to get the output in the format 28th Apr 2005.

FORM set_text_date.

DATA: month(9),

year(4),

date(2).

CASE p_frd+4(2).

WHEN '01'.

month = 'January'.

WHEN '02'.

month = 'February'.

WHEN '03'.

month = 'March'.

WHEN '04'.

month = 'April'.

WHEN '05'.

month = 'May'.

WHEN '06'.

month = 'June'.

WHEN '07'.

month = 'July'.

WHEN '08'.

month = 'August'.

WHEN '09'.

month = 'September'.

WHEN '10'.

month = 'October'.

WHEN '11'.

month = 'November'.

WHEN '12'.

month = 'December'.

WHEN OTHERS.

ENDCASE.

WRITE p_frd+0(4) TO year.

WRITE p_frd+6(2) TO date.

CONCATENATE month date ',' year INTO return_date SEPARATED BY space.

CONDENSE return_date.

ENDFORM.

-


ALSO PLEASE CHECK OUT THE LINK BELOW IT WILL TELL YOU

Different method of Converting Date

http://www.sap-basis-abap.com/sapab015.htm

*********please reward points if the information is helpful to you************