Changeset 12740 in osm for applications/editors/josm/plugins
- Timestamp:
- 2008-12-31T21:33:29+01:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/agpifoj/src/org/openstreetmap/josm/plugins/agpifoj/CorrelateGpxWithImages.java
r12707 r12740 578 578 gpstimezone = timezoneValue.floatValue(); 579 579 580 try { 581 delta = Long.parseLong(tfOffset.getText()); 582 } catch(NumberFormatException nfe) { 583 JOptionPane.showMessageDialog(Main.parent, tr("Error while parsing offset.\nExpected format: {0}", "number"), 584 tr("Invalid offset"), JOptionPane.ERROR_MESSAGE); 585 continue; 580 String deltaText = tfOffset.getText().trim(); 581 if (deltaText.length() > 0) { 582 try { 583 delta = Long.parseLong(deltaText); 584 } catch(NumberFormatException nfe) { 585 JOptionPane.showMessageDialog(Main.parent, tr("Error while parsing offset.\nExpected format: {0}", "number"), 586 tr("Invalid offset"), JOptionPane.ERROR_MESSAGE); 587 continue; 588 } 589 } else { 590 delta = 0; 586 591 } 587 592 … … 804 809 805 810 private Float parseTimezone(String timezone) { 811 if (timezone.length() == 0) { 812 return new Float(0); 813 } 814 806 815 char sgnTimezone = '+'; 807 String hTimezone = "";808 String mTimezone = "";816 StringBuffer hTimezone = new StringBuffer(); 817 StringBuffer mTimezone = new StringBuffer(); 809 818 int state = 1; // 1=start/sign, 2=hours, 3=minutes. 810 819 for (int i = 0; i < timezone.length(); i++) { … … 837 846 switch(state) { 838 847 case 1 : 848 case 2 : 839 849 state = 2; 840 hTimezone += c; 841 break; 842 case 2 : 843 hTimezone += c; 850 hTimezone.append(c); 844 851 break; 845 852 case 3 : 846 mTimezone += c;853 mTimezone.append(c); 847 854 break; 848 855 default : … … 854 861 } 855 862 } 856 int h = Integer.parseInt(hTimezone); 857 int m = Integer.parseInt(mTimezone); 863 864 int h = 0; 865 int m = 0; 866 try { 867 h = Integer.parseInt(hTimezone.toString()); 868 if (mTimezone.length() > 0) { 869 m = Integer.parseInt(mTimezone.toString()); 870 } 871 } catch (NumberFormatException nfe) { 872 // Invalid timezone 873 return null; 874 } 875 858 876 if (h > 12 || m > 59 ) { 859 877 return null; 860 } 861 return new Float((h + m / 60.0) * (sgnTimezone == '-' ? -1 : 1)); 878 } else { 879 return new Float((h + m / 60.0) * (sgnTimezone == '-' ? -1 : 1)); 880 } 862 881 } 863 882
Note:
See TracChangeset
for help on using the changeset viewer.