I have these two methods that are written right now. As the scenario goes, when I grab a data field from the database, it is in BigDecimal format. So I decided to write a test for it (the formatDate() method). I pass in the BigDecimal to the method, but it appears I have written some peice of this code wrong. From what I have seen in examples and the SimpleDateFormat API, I think I have written the code correctly, but I cannot seem to figure out what is going wrong to have it throw a parseEx. Can someone give me a hint at what is going on?
private void loadMap() {
//TODO: Uncomment when finished testing.
//DO OTHER STUFF
BigDecimal bd = new BigDecimal(12051998);
System.out.println(formatDate(bd));
}
private String formatDate(BigDecimal bd) {
String value = bd.toString();
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy");
try {
return format.parse(value);
} catch (ParseException pEx) {
logger.error(pEx);
return "Bad Date Format";
}
}
Thanks in advance, Warmest Regards,
- Josh