cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the next Date

Former Member
0 Kudos

Hi All,

I have a date field in which when i enter the date and click on the button I should display the next day in another inputfield.

Ex: If i enter 12th Nov 2008 (11/12/2008)i should get 13th Nov 2008 (11/13/2008)

in the other input field.

Thank You in Advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Following is the sample code based on todays date



Date dt = new Date(Calendar.getInstance().getTimeInMillis());
		Calendar calendar = Calendar.getInstance();
		calendar.add(Calendar.DATE, 1);
		System.out.println(calendar.getTime());

OR
//Specifically for your sample dates
Calendar calendar = Calendar.getInstance();
		calendar.set(Calendar.MONTH, 10);
		calendar.set(Calendar.DATE, 12);
		calendar.set(Calendar.YEAR, 2008);
		System.out.println(calendar.getTime());
		calendar.add(Calendar.DATE, 1);
		System.out.println(calendar.getTime());


Regards

Ayyapparaj

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi All,

I got the date format right now.This is the code that I have written.

Date d1 = wdContext.currentContextElement.getDate();

calendar.set(d1.getYear() + 1900,d1.getMonth(),d1.getDate());

calendar.add(Calendar.DATE, 1);

int mnth = calendar.get(Calendar.MONTH);

mnth = mnth+1;

wdComponentAPI.getMessageManager().reportSuccess(mnth "/"calendar.get(Calendar.DATE)"/"calendar.get(Calendar.YEAR));

Thankx,

Naaz.

Former Member
0 Kudos

Hi,

This is the code I am writing to display the date in the message manager.

wdComponentAPI.getMessageManager().reportSuccess(calendar.get(Calendar.MONTH)"/"calendar.get(Calendar.DATE)"/"calendar.get(Calendar.YEAR));

I am getting the output as :10/8/108.

Former Member
0 Kudos

..and what is the problem? To format the date, have a look at classes DateFormat, SimpleDateFormat etc.

In the InputField the format is determined by the context attribute type and the formatting is done by the Java DDIC classes.

Armin

Former Member
0 Kudos

Hi Ayyapparaj,

Thankx for the quick reply.I got the date but its displaying in this format :Thu Nov 13 09:07:58 EST 2008 .I want it as 11/13/2008 format.

Thank You,

Naaz

Former Member
0 Kudos

Give the context attribute to which your input field is bound the type "date" (which corresponds to java.sql.Date at runtime).

Armin