I'm using the POI api in Java. To get the time in an excel spreadsheet. In the excell spreadsheet the data is as text
publicvoidobterHora(){Cellhora=row.getCell(7);System.out.println("hora: "+hora);
}
result: Dec 31, 1899
The solution to this problem was this:
public void obterHora(){
String hora;
int h=row.getCell(7).getDateCellValue().getHours();
int m=row.getCell(7).getDateCellValue().getMinutes();
int s=row.getCell(7).getDateCellValue().getSeconds();
hora = h+":"+m+":"+s;
SimpleDateFormat formatador = new SimpleDateFormat("HH:mm:ss");
Date data = formatador.parse(horario);
horaAgen = new Time(data.getTime());
System.out.println("hora: "+horaAgen);
}
Result:
9:00 AM 12:00 PM
Always in format
HH: mm: ss
This way you have met my needs