Created
March 25, 2013 09:11
-
-
Save zyxar/5235874 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static java.lang.System.out; | |
public class PDU { | |
public static void main(String [] args) { | |
String smsc = args[0]; | |
String smsc_format = "92"; | |
if(smsc.substring(0,1).equals("+")) { | |
smsc_format = "91"; | |
smsc = smsc.substring(1); | |
} | |
else if(!smsc.substring(0,1).equals("0")) { | |
smsc_format="91"; | |
} | |
else {} | |
if (smsc.length() %2 != 0) { | |
smsc += 'F'; | |
} | |
String smsc_number = convert(smsc); | |
smsc = smsc_format + smsc_number; | |
int smsc_length = smsc.length() / 2; | |
if (smsc_length < 10) { | |
smsc = "0" + smsc_length + smsc; | |
} else { | |
smsc = smsc_length + smsc; | |
} | |
out.println("smsc_format = " + smsc_format); | |
out.println("smsc = " + smsc); | |
} | |
private static String convert(String input) { | |
char[] output = new char[input.length()]; | |
for (int i = 0; i < input.length(); ++i ){ | |
if ( i % 2 == 0 ) { | |
output[i] = input.charAt(i+1); | |
} else { | |
output[i] = input.charAt(i-1); | |
} | |
} | |
return new String(output); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment