Skip to Content
avatar image
Former Member

creating date field

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    Sep 12, 2008 at 05:04 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 12, 2008 at 04:41 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 12, 2008 at 04:45 AM

    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);

    }

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 12, 2008 at 04:57 AM

    hi,

    to achieve dd/mm/yyyy refer the following thread

    date-format-in-table

    Regards,

    ramesh.

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 12, 2008 at 05:34 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 12, 2008 at 06:54 AM

    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

    Add comment
    10|10000 characters needed characters exceeded