Changeset 471 in tmcsimulator for trunk/src/tmcsim/cadsimulator/Coordinator.java
- Timestamp:
- 07/29/2019 01:36:40 PM (7 years ago)
- File:
-
- 1 edited
-
trunk/src/tmcsim/cadsimulator/Coordinator.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/cadsimulator/Coordinator.java
r466 r471 837 837 public int compare(String o1, String o2) 838 838 { 839 return extractInt(o1) - extractInt(o2); 839 // extract just the timestamp from the strings and convert them to int 840 // fixes #181 841 return extractInt(o1.substring(0,8)) - extractInt(o2.substring(0,8)); 840 842 } 841 843 // extract an integer from a String … … 843 845 { // remove all non-digits 844 846 String num = s.replaceAll("\\D", ""); 845 // return 0 if no digits found, else return the number 846 return num.isEmpty() ? 0 : Integer.parseInt(num); 847 try 848 { 849 // return 0 if no digits found, else return the number 850 return num.isEmpty() ? 0 : Integer.parseInt(num); 851 } catch (NumberFormatException ex) 852 { 853 System.out.println("Can't convert "+s+" to integer in writeToCAD. " + 854 ex.getMessage()); 855 return 0; 856 } 847 857 } 848 858 });
Note: See TracChangeset
for help on using the changeset viewer.
