• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Reading the Date and time values from excel sheet

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys ,
iam trying to read excel sheet data using apache poi api .my problem is i cant read the date(dd/mm/yy) and time(hh:mm:ss) values concurrently from two different cells .when iam trying to do so iam getting the values in either time format or data format but not both the below is the sample code please post your answers with sample code


if (HSSFDateUtil.isCellDateFormatted(cell)) {
// format in form of M/D/YY

cal.setTime(HSSFDateUtil.getJavaDate(num));
cellText = (String.valueOf(cal.get(Calendar.YEAR))).substring(2);
cellText = cal.get(Calendar.MONTH)+1 + “/” +cal.get(Calendar.DAY_OF_MONTH) + “/” +cellText;

// cal.setTime(cell.getDateCellValue());

datetext = cal.get(Calendar.HOUR) + “:” +cal.get(Calendar.MINUTE) + “:” +cal.get(Calendar.SECOND);

}
 
Greenhorn
Posts: 2
Netbeans IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sridhar, here's what I tried..
I used an Excel 2007 format sheet with 6/22/2011 in cell A1 and 15:16:17 in cell B1. Since this is Excel 2007, I used the XSSF classes instead of HSSF.



That gives me the date as Wed Jun 22 03:16:17 GMT+05:30 2011
Hope that helps!
 
I think I'll just lie down here for a second. And ponder this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic