FileDocCategorySizeDatePackage
CldcUtils.javaAPI DocphoneME MR2 API (J2ME)5890Wed May 02 18:00:44 BST 2007com.sun.j2me.payment

CldcUtils

public class CldcUtils extends Utils
This class implements utility methods used in the com.sun.j2me.payment package.
version

Fields Summary
public static final int
PAYMENT_ID_OFFSET
The offset value between Utils and ResourceConstants resource keys.
Constructors Summary
public CldcUtils()
Creates a new instance of CldcUtils.


           
      
    
Methods Summary
public java.lang.StringformatISODate(long date)
Converts the given date to the string formatted according to the ISO 8601 standard.

param
date the date as the number of milliseconds elapsed since 1970-1-1 GMT
return
the date string

        TimeZone gmtTimeZone = TimeZone.getTimeZone("GMT");
        Calendar gmtCalendar = Calendar.getInstance(gmtTimeZone);
        
        gmtCalendar.setTime(new Date(date));
        
        StringBuffer buffer = new StringBuffer();
        char[] temp = new char[4];
        
        formatNumber(temp, gmtCalendar.get(Calendar.YEAR), 4);
        buffer.append(temp, 0, 4);
        buffer.append('-");
        formatNumber(temp, gmtCalendar.get(Calendar.MONTH) + 1, 2);
        buffer.append(temp, 0, 2);
        buffer.append('-");
        formatNumber(temp, gmtCalendar.get(Calendar.DAY_OF_MONTH), 2);
        buffer.append(temp, 0, 2);
        buffer.append(' ");

        formatNumber(temp, gmtCalendar.get(Calendar.HOUR_OF_DAY), 2);
        buffer.append(temp, 0, 2);
        buffer.append(':");
        formatNumber(temp, gmtCalendar.get(Calendar.MINUTE), 2);
        buffer.append(temp, 0, 2);
        buffer.append(':");
        formatNumber(temp, gmtCalendar.get(Calendar.SECOND), 2);
        buffer.append(temp, 0, 2);

        buffer.append('Z");
        
        return buffer.toString();
    
private voidformatNumber(char[] dest, int number, int digits)

        int index = digits;
        while (index > 0) {
            dest[--index] = (char)((number % 10) + '0");
            number = number / 10;
        }
    
public java.lang.StringgetString(int key)
Returns a resource string for the given key.

param
key the key
return
the string assigned to the key

        if (key >= PAYMENT_ID_OFFSET) {
            key -= PAYMENT_ID_OFFSET;
        }
        return Resource.getString(key);
    
public java.lang.StringgetString(int key, java.lang.String[] values)
Returns a modified resource string for the given key. It replaces any occurence of %1, %2, ... in the original resource string with the first, second, ... string from values.

param
key the key
param
values the replacement strings
return
the modified resource string

        if (key >= PAYMENT_ID_OFFSET) {
            key -= PAYMENT_ID_OFFSET;
        }
        return Resource.getString(key, values);
    
public com.sun.midp.util.PropertiesloadProperties(java.io.InputStream is, java.lang.String charset)
Parses properties from the given input stream and returns them as an instance of the Properties class. The charset parameter contains the actual character encoding of the input stream.

param
is the input stream which contains properties
param
charset the character set of the input stream
return
the properties read from the stream
throws
UnsupportedEncodingException if charset is not supported by the implementation
throws
IOException if the input stream doesn't have properties in the correct format

        JadProperties props = new JadProperties();
        props.load(is, charset);
        
        return props;
    
public longparseISODate(java.lang.String date)
Parses a date string according to the ISO 8601 standard.

param
date the date string in the format YYYY-MM-DDTHH:MM[:SS][[+|-] HH[MM]]
return
the number of milliseconds elapsed since 1970-1-1 GMT to this date
throws
IllegalArgumentException if the format of the date string is incorrect or the date is invalid

        return DateParser.parseISO(date);