Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int SumaNumar(String textDate){
- String pattern = "sysdate";
- int daysCalc = 0;
- String operations = "";
- int numarFormat = 0;
- int semn=1;
- int indexSysdate = textDate.indexOf(pattern);
- int start = indexSysdate + pattern.length();
- System.out.println("start: " + start);
- if(indexSysdate != -1){
- operations = textDate.substring(start);
- operations.trim();
- System.out.println("Numarul: " + operations);
- for(int i = 0;i<=operations.length()-1;i++) {
- char iterate = operations.charAt(i);
- int gasit = 0;
- int gasitnr = 0;
- if(Character.isDigit(iterate)){
- gasit = Character.getNumericValue(iterate);
- numarFormat = numarFormat * 10 + gasit;
- System.out.println("Numarul: " + numarFormat);
- }
- //+234-32-42+4242
- if(Character.toString(iterate).equals("+")) {
- gasitnr = numarFormat;
- daysCalc += gasitnr*semn;
- numarFormat = 0;
- System.out.println("Adunarea: " + daysCalc);
- }
- //+234-32-42+4242
- if(Character.toString(iterate).equals("-")) {
- semn = -1;
- gasitnr = numarFormat;
- daysCalc += gasitnr*semn;
- numarFormat = 0;
- System.out.println("Scaderea: " + daysCalc);
- }
- }
- }
- return daysCalc;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement