cancel
Showing results for 
Search instead for 
Did you mean: 

creating date field

Former Member
0 Kudos

hai every one,

i want develop two date fileds.

i taken two input fields like date1 and date2 and given type as Date.

here the date input format is like mm/dd/yyyy, but i want to change to dd/mm/yyyy.

And i want to maintain condition like date2 >= date1.

if it is wrong i need to show error.

Accepted Solutions (1)

Accepted Solutions (1)

lokesh_kamana
Active Contributor
0 Kudos

Hi,

This is an addition to nihils thread.


Format formatter = new SimpleDateFormat("MMM dd,yyyy");

formatter.format(wdContext.nodexxxx().getXX.getAssig_Date())

Thanks & Regards,

Lokesh

Answers (5)

Answers (5)

Former Member
0 Kudos

hi

To Get the Date in your required format use SimpleDateFormatter

public Date getDate(String dateString)

{

// TODO : Implement

java.util.Date d= null;

SimpleDateFormat FORMATTER = new SimpleDateFormat("dd.MM.yyyy");

try

{

d = FORMATTER.parse(dateString);

}

catch (ParseException e)

{

wdComponentAPI.getMessageManager().reportException("Unable to do operation, error is:"+e,true);

}

return new Date(d.getTime());

}

You can use above method to format you date ...

Now if you want to compare the dates

methods like after ,before ,equals are available on the date.

But date1.equals(date2) will return true only when the time of

the two dates are equals(i.e it see hrs,min,sec,milliseconds..)etc

If this is the requirement of you You can use it.

But You just want to compare the Dates are equal,

Then you have to go for the Calender Object ....

If any queries or more help needed reply back

Regards

Madhavi

lokesh_kamana
Active Contributor
0 Kudos

Hi,

try this it is more usefull


			SimpleDateFormat fSDateFormat = new SimpleDateFormat ("dd/MM/yyyy");
		 	Date now = new Date ();
			mdr.reportSuccess(now.toString());
		  	String date_out = fSDateFormat.format (now);
			mdr.reportSuccess(date_out.toString());

Thanks & Regards,

Lokesh

Former Member
0 Kudos

hi,

to achieve dd/mm/yyyy refer the following thread

Regards,

ramesh.

Former Member
0 Kudos

1. Go to dictionaries.

2. There, in Simple Types, create a new simple type , eg. ca_Data1, ca_Date2.

3. After creating, there is a format field where you can define the format of date as required.

for validation of Date2 >= Date1 , write the following code :-

if((wdcontext.node ***. current (node) element.get date1) < (wdcontext.node ***. current (node) element.get date))

{

wdcomponentAPI.getmessagemanager.reportexception("condition wrong",false);

}

Former Member
0 Kudos

Eswar, you could use a InputField UI element and map it to a Context Element of type Date. This would allow the user to pick dates. Post this on some action you will have to use the java date API to do the checks you require.

Thanks,

GLM