Java源码示例:org.jsmpp.util.TimeFormatter

示例1
public static void main(String[] args) throws Exception {
    SMPPSession session = null; // 1. initialize
    // 2. Initiate bind
    // 3. Set message receiver listener if needed
    
    // this is how to write "house" in arabic
    String house = "\u0628" + "\u064e" + "\u064a" + 
                    "\u0652" + "\u067a" + "\u064f";
    
    TimeFormatter timeFormatter = new RelativeTimeFormatter();
    
    
    // 4. Specify the data coding using UCS2
    DataCoding dataCoding = new GeneralDataCoding(Alphabet.ALPHA_UCS2, MessageClass.CLASS1, false);
    
    // 5. UTF-16BE is equals to UCS2
    byte[] data = house.getBytes("UTF-16BE");
    
    // 6. Submit the short message
    String messageId = session.submitShortMessage("CMT", 
            TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.UNKNOWN, 
            "1616", TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.UNKNOWN, 
            "628176504657", new ESMClass(), (byte)0, (byte)1,  
            timeFormatter.format(new Date()), null, 
            new RegisteredDelivery(SMSCDeliveryReceipt.DEFAULT), (byte)0, 
            dataCoding, 
            (byte)0, data);
}