cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in Date filed in Upload Excel Sheet Program

Former Member
0 Kudos

Hi Friends,

I have one doubt on File upload. After downloading data into excel Sheet I have to modify some columns in the excel sheet then I am trying to upload same excel sheet to table.

I am getting problem in date column. I have written this code for upload excel file

boolean flag = false;

try

{

Path: here I am getting file from the server path

wb = Workbook.getWorkbook(new File(path)); // For Dev

Sheet sh = wb.getSheet(0);

int cloumns = sh.getColumns();

int row = sh.getRows();

int i = 0;

for(int j=1; j<row ; j++)

{

IPrivatePO_Details_ResultView.IPoDetails_OutTabElement ele = wdContext.nodePoDetails_OutTab().createPoDetails_OutTabElement();

ele.setChcekBoxEnable(true);

Cell c1 = sh.getCell(i,j);

ele.setPo_Number(c1.getContents());

BigDecimal bdStr = null;

Cell c7 = sh.getCell(i+6,j);

bdStr = new BigDecimal(c7.getContents());

ele.setQuantity(bdStr);

Cell c8 = sh.getCell(i+7,j);

bdStr = new BigDecimal(c8.getContents());

ele.setOa_Quantity(bdStr);

SimpleDateFormat smDate = smDate = new SimpleDateFormat("dd-MM-yyyy");

Date dt = null;

Cell c10 = sh.getCell(i+9,j);

*dt = (Date)smDate.parse(c10.getContents()); *

ele.setDeliv_Date(dt);

Cell c11 = sh.getCell(i+10,j);

dt = (Date)smDate.parse(c11.getContents());

ele.setStat_Date(dt);

Cell c14 = sh.getCell(i+13,j);

ele.setPo_Status(c14.getContents());

wdContext.nodePoDetails_OutTab().addElement(ele);

}

}

catch(Exception Ex)

{

Ex.printStackTrace();

}

Here PoDetails_OutTab this is value node under this value node Deliv_Date is available the date data type is date.

Please help me.

Regards

Vijay Kalluri

Accepted Solutions (1)

Accepted Solutions (1)

p330068
Active Contributor
0 Kudos

Hi Vijay,

Please check below code :-

Date dt = null;

SimpleDateFormat smDate = null;

smDate = new SimpleDateFormat("dd-MM-yyyy");

Cell c10 = sh.getCell(i+9,j);

dt = (Date)smDate.parse(c10.getContents());

ele.setDeliv_Date(dt);

Code if ok now. Please check the value for c10 using message manager and analyze the value that is ok for DATE or not.

Hope it helps

Regards

Arun

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

Please use below code

patt="dd.mm.yyyy"

java.text.SimpleDateFormat backendformat;

backendformat = new SimpleDateFormat("yyyymmdd");

java.util.Date date_hired= null;

date_hired = backendformat.parse(hireddate);

backendformat.applyPattern(patt);

Regards

Dibya

former_member214651
Active Contributor
0 Kudos

Hi,

Which Date type are u using- java.util.Date or java.sql.Date?

Regards,

Poojith MV

Former Member
0 Kudos

Hi Poojith,

Here I am using import java.sql.Date; this date type. When download the data to Excel sheet that time in date attribute is converted to string after download the data in to Excel Sheet.

Regards

Vijay Kalluri

Former Member
0 Kudos

Vijay,

Please check the format of the date you are getting while readinng from edited excel. based on that format; use SimpleDateFormat.

regards,

Gangadhar