cancel
Showing results for 
Search instead for 
Did you mean: 

Date format problem in webdynpro

Former Member
0 Kudos

We are trying to display the join date of employees in a table. It gives mm/dd/yyyy format.

We want the date in dd/mm/yyyy format .Can anyone help me with the code for this?

Accepted Solutions (0)

Answers (9)

Answers (9)

Former Member
0 Kudos

Hi

Use this code for getting your desired date format

Date dateToBeChanged=<your retrived date from BAPI>;
Format formatter = new SimpleDateFormat("dd/MM/yyyy");
String tempDate = formatter.format(dateToBeChanged);

Now in tempDate you will get your desired date's format

Regards

Chandran S

Former Member
0 Kudos

Hi,

You can use followin code

TimeZone tz = TimeZone.getTimeZone("GMT+05:30");//set time zone according to your place

SimpleDateFormat formatter =(SimpleDateFormat)DateFormat.getDateTimeInstance(DateFormat.LONG,

DateFormat.LONG, Locale.US);

formatter.setTimeZone(tz);

formatter.applyPattern("MM/dd/yyyy");

String datestr =formatter.format(Rdate);

This will give the date as string in required format .

Regards

Deepak

Former Member
0 Kudos

Hi,

Make use of the following code



IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute("Your Date attribute");
	  attributeInfo.getDataAttribute().getScalarType().format("dd/MM/yyyy");
 

Regards

Ayyapparaj

Former Member
0 Kudos

Hi,

Change the default language to "Hindi" in the Web browser that you use and close the browser and again try to run the same.

This will work.

If its possible just help me how to change the format of a date picker in WD. Right now its mm/dd/yyyy and i want it in dd/mm/yyyy.

Regards

- Vinod

  • Reward if found helpful.

Edited by: Vinod V on Feb 29, 2008 11:34 AM

Former Member
0 Kudos

Hi,

-Create a simple data type

-In Representation - Format - specify dd/mm/yyyy

-Assign this simple data type to required column in ur table.

-

Shyam.

Former Member
0 Kudos

Thankyou for your help .But the datasource of my table is a model .Then how can i assign a simple type to a column in that table? plz reply

chintan_virani
Active Contributor
0 Kudos

Anzar,

If the value is coming from the backend and you just want to display as dd/MM/yyyy then in wdDoInit() of your View do the following --> get the current date value, format it as per your need and then set it back.

	// Check the size of the nodeelement which contains your atribute.
	int size = wdContext.node<NodeName>().size();

       // Loop over and set the value
	for (int i = 0; i < size; i++)
	{
		String strJoinDtModel = wdContext.current<NodeName>Element().get<AttributeName>.toString();
		String strNewDtJoin = formatDate("strJoinDtModel");
		wdContext.current<NodeName>Element().set<AttributeName>(strNewDtJoin);
	}

So if u have following hierarchy

Employee (ModelNode)

|---- JoinDate (Model Attrribute)

then NodeName = Employee and AtrributeName = JoinDate in above code snippet.

You will need to create a formatDate() method as follows:-

public String formatDate(String strDate)
  {
	SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); // Note the uppercase for month.
	String newDate =  sdf.format(strDate);
	return newDate;
  }

Former Member
0 Kudos

Hi ,

u can do it in 2 ways

1) for stand alone applications In Control Panel ->Regional and Language Options change the languaue settings to English UK.

2) for portal applications In User Administration while creating a user give language as English UK , for exsisting users modify language to English UK.

Thanks,

Sunitha Hari

Former Member
0 Kudos
Former Member
0 Kudos

Hi,

Use the following:

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

String dateReturn = dateFormat.format(<Your Date>) ;

Hope this helps.

thanks & regards,

Manoj

Former Member
0 Kudos

hai the following are some func modules availabel for date conversion.you can make use of it.

CONVERSION_EXIT_LDATE_OUTPUT – Converts date format

CONVERT_DATE_TO_EXTERNAL – Formats date from internal to display format

CONVERT_DATE_TO_INTERNAL – Formats date from display to internal format

DATE_CONV_EXT_TO_INT – Conversion of dates to SAP’s internal format

DATE_CONVERT_TO_FACTORYDATE – Converts calendar date into factory day

DATE_CONVERT_TO_WORKINGDAY – Converts a calendar

Thanks n Regards

Sharanya.R

Former Member
0 Kudos

Hi,

Use this code:

java.util.Calendar cal = java.util.Calendar.getInstance();

cal.setTime(quotationValidFrom);

//cal.set(quotationValidFrom.getYear(),quotationValidFrom.getMonth(),quotationValidFrom.getDate());

cal.add(java.util.Calendar.DATE, NoOfDays+1);

//String sAddDate = cal.getTime().toGMTString();

String DATE_FORMAT = "dd-MM-yyyy";

java.text.SimpleDateFormat sdf =

new java.text.SimpleDateFormat(DATE_FORMAT);

//requestedDeliveryDate.setTime(cal.getTime().to);

String ReqDate = sdf.format(cal.getTime());

Regards,

Kiran Yadav