Scout/Tutorial/3.8/webservices/Conversion methods for StockQuote service

From Eclipsepedia

< Scout‎ | Tutorial‎ | 3.8
Revision as of 02:56, 17 October 2012 by Jbr.bsiag.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Scout
Wiki Home
Website
DownloadGit
Community
ForumsBlogTwitter
Bugzilla
Bugzilla


private Date parseDateTime(String date, String time) {
  try {
    if (date != null && !date.equals("N/A") && time != null && !time.equals("N/A")) {
      SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy hh:mmaa");
      return format.parse(date + " " + time);
    }
    else if (date != null && !date.equals("N/A")) {
      SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy");
      return format.parse(date);
    }
    else if (time != null && !time.equals("N/A")) {
      SimpleDateFormat format = new SimpleDateFormat("hh:mmaa");
      return format.parse(time);
    }
  }
  catch (ParseException e) {
    ScoutLogManager.getLogger(CompanyProcessService.class).error("failed to parse date/time '" + date + " " + time + "'", e);
  }
  return null;
}
 
private Double parseDouble(String number) {
  if (number != null && number.equals("N/A")) {
    return null;
  }
  try {
    return Double.parseDouble(number);
  }
  catch (Exception e) {
    ScoutLogManager.getLogger(CompanyProcessService.class).error("failed to parse double value '" + number + "'", e);
  }
  return null;
}
 
private Long parseLong(String number) {
  if (number != null && number.equals("N/A")) {
    return null;
  }
  try {
    return Long.parseLong(number);
  }
  catch (Exception e) {
    ScoutLogManager.getLogger(CompanyProcessService.class).error("failed to parse long value '" + number + "'", e);
  }
  return null;
}