cancel
Showing results for 
Search instead for 
Did you mean: 

COMBINING DATE

Former Member
0 Kudos

hi,

I am getting the date in the format mm/dd/yyyy

but i want to get it in the format yyyyddmm without extra characters

Waiting for a positive reply

with regards,

kiruthika.s

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

hai,

create a simple type of type date, select the tab reperesentATION, HERE YOU CAN GIVE FORMAT yyyyddMM .

bind this attribute to input field.

the date will taken in this format.

regards,

Former Member
0 Kudos

Prabhu,


SimpleDateFormat fmtDateDelim = new SimpleDateFormat("MM/dd/yyyy");
Date parsedDate = fmtDateDelim.parse("07/24/2006");
SimpleDateFormat fmtDatePlain = new SimpleDateFormat("yyyyMMdd");
String formattedDate =  fmtDatePlain.format(parsedDate);

VS

vijayakhanna_raman
Active Contributor
0 Kudos

Hi,

This code below will convert the date format but change the code to ur format what u need.

then u can use String tokanizer to separate the "/".

And combine the date.

String oldFormatData = "2006/07/17";

String newFormatData;

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

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

Date old1 =null;

try {

old1= old.parse(oldFormatData);

} catch (ParseException e) {

wdComponentAPI.getMessageManager().reportException(""+e,true);

}

newFormatData = new1.format(old1);

wdComponentAPI.getMessageManager().reportSuccess("Date"+newFormatData);

Regards.

Vijayakhanna Raman

Former Member
0 Kudos

Vijayakhanna,

See original post -- you confused "old" and "new" format. Also new format ("old" variable in your code) must have no delimeters according to task, i.e. SimpleDateFormat("yyyyMMdd").

VS

vijayakhanna_raman
Active Contributor
0 Kudos

Hi,

Check this code,

String oldFormatData = "24/07/2006";

String newFormatData;

SimpleDateFormat new1= new SimpleDateFormat("yyyyMMdd");

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

Date old1 =null;

try {

old1= old.parse(oldFormatData);

} catch (ParseException e) {

wdComponentAPI.getMessageManager().reportException(""+e,true);

}

newFormatData = new1.format(old1);

Regards,

Vijayakhanna Raman

Former Member
0 Kudos

HI you can use this,

First you can convert the date to String.

String chDate=String.valueOf(Date ) int yy=Integer.parseInt(chDate.substring(0,chDate.indexOf("-")));

String balda=chDate.substring(chDate.indexOf("-")+1);

int mm=Integer.parseInt(balda.substring(0,balda.indexOf("-")));

int dd=Integer.parseInt(balda.substring(balda.indexOf("-")+1));

String date=yyyyddmm

P.s:I use the delimeter - You can use the delimeter you get in date

Former Member
0 Kudos