cancel
Showing results for 
Search instead for 
Did you mean: 

how to change the input date to next date...........!

Former Member
0 Kudos

hi,

I have the following requirement:

I have a source field as "DOJ" and Target Field as "Date"

I want the output as follows:

Input:

DOJ = 12/12/2008 (dd/MM/yyyy)

Output:

Date =13/12/2008 (dd/MM/yyyy)

the requirement is whenever the source filed ie (DOJ) is given a value ie date ="12/12/2008" then the target filed ie (Date) should give the next day's date ie 13/12/2008

pls do let me know ......how to do this .........?

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Thanks .........!

Former Member
0 Kudos

Hi,

You can just create a User defined function an add 1 to your day in the date.

Substring your current date to get month, day and year into seperate variables.. then u can just add one to your day and re group it as a single string..

here is a sample code

String date = "12/04/2008";

String day = date.substring(0,2);

String month = date.substring(3,5);

String year = date.substring(6,10);

int next =Integer.parseInt(day)+1;

String nextDay = String.valueOf(next);

String nextDate = nextDay + "/" +month "/"year;

Hope it helps.

Cheers

Mohan.

Edited by: Krishnamohan Adiraju on Dec 5, 2008 12:13 PM

Edited by: Krishnamohan Adiraju on Dec 5, 2008 12:14 PM

SudhirT
Active Contributor
0 Kudos

Hi,

Check this for the answer

Thanks!

Former Member
0 Kudos

Hi,

Try this UDF it will surely work;

try

{

Date dat = new SimpleDateFormat("dd/MM/yyyy").parse(a[0]);

Calendar cal = new GregorianCalendar();

cal.setTime(dat);

cal.add(Calendar.DAY_OF_MONTH, +1);

Date bar = cal.getTime();

String expDate = new SimpleDateFormat("dd/MM/yyyy").format(bar);

result.addValue(expDate);

}

catch(Exception ex)

{

System.out.println(ex);

}

Former Member
0 Kudos

thank you .......Murugavel ..........problem got solved ...........!

Aziz khan

Former Member
0 Kudos

Same question.. answered here.....