Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

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

< Scout‎ | Tutorial‎ | 5.0
Revision as of 06:35, 31 March 2015 by Ssw.bsiag.com (Talk | contribs) (Created page with "{{ScoutPage|cat=Tutorial 5.0}} <source lang="java"> private Date parseDateTime(String date, String time) { try { if (date != null && !date.equals("N/A") && time != null...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The Scout documentation has been moved to https://eclipsescout.github.io/.

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(CompanyService.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(CompanyService.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(CompanyService.class).error("failed to parse long value '" + number + "'", e);
  }
  return null;
}

Back to the top