"Java Practice" 6-2.GPS data processing

Source: Internet
Author: User

1  PackageMian;2 3 ImportJava.util.Scanner;4 5  Public classMain {6 7      Public Static voidMain (string[] args) {8         //TODO auto-generated Method Stub9Scanner in =NewScanner (system.in);TenString s =NULL, S2 =NULL; One         intCak; A         intB, UTC; -         BooleanFlag =true; -          Do { thes =In.next (); -             if(S.equals ("END")) {//End Judgment -Flag =false; -             } +             Else if(S.indexof ("$GPRMC") = = 0) {//1. $GPRMC sentence judgment -Cak = S.charat (S.indexof (1)); +                  for(inti = 2; I < S.indexof (' * '); ++i) { ACak ^= S.charat (i);//calculate an XOR value at                 } -Cak%= 65536; -                 if(Cak = = Integer.parseint (s.substring (S.indexof (' * ') +1), +) && s.indexof (", A,")! =-1) {//determine if the XOR value is correct, and whether it is positioned.  -S2 = "" + S;//new string saved in S2 -                 } -             } in} while(flag); -s = s2.substring (1);//get the correct string toUTC = Integer.parseint (s.substring (7, 13));//get UTC Value +B = UTC + 80000;//get the value of GMT -s = ":" + string.valueof (b). substring (string.valueof (b). Length ()-2);//the number of seconds is converted to a string containing the leading thes = ":" + string.valueof (b). substring (string.valueof (b). Length ()-4, string.valueof (b). Length ()-2) + s;//Convert fractions into strings *B/= 10000; $         if(B >= 24) {Panax NotoginsengB-= 24; -         } the         if(B >= 10) { +s = string.valueof (B) +s; A         } the         Else if(b < && b >= 0) { +s = "0" + string.valueof (B) +s; -         } $ System.out.println (s); $ in.close (); -     } -  the}

"Java Practice" 6-2.GPS data processing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.