* hour is set to fields[1], minute is set to fields[2] and second is
* set to fields[3].
* @return Returns true when the given custom id is valid.
*/
static boolean parseCustomID(String id, int[] fields) {
NumberFormat numberFormat = null;
String idUppercase = id.toUpperCase();
if (id != null && id.length() > kGMT_ID.length() &&
idUppercase.startsWith(kGMT_ID)) {
ParsePosition pos = new ParsePosition(kGMT_ID.length());
int sign = 1;
int hour = 0;
int min = 0;
int sec = 0;
if (id.charAt(pos.getIndex()) == 0x002D /*'-'*/) {
sign = -1;
} else if (id.charAt(pos.getIndex()) != 0x002B /*'+'*/) {
return false;
}
pos.setIndex(pos.getIndex() + 1);
numberFormat = NumberFormat.getInstance();
numberFormat.setParseIntegerOnly(true);
// Look for either hh:mm, hhmm, or hh
int start = pos.getIndex();
Number n = numberFormat.parse(id, pos);
if (pos.getIndex() == start) {
return false;
}
hour = n.intValue();
if (pos.getIndex() < id.length()){
if (pos.getIndex() - start > 2
|| id.charAt(pos.getIndex()) != 0x003A /*':'*/) {
return false;
}
// hh:mm
pos.setIndex(pos.getIndex() + 1);
int oldPos = pos.getIndex();
n = numberFormat.parse(id, pos);
if ((pos.getIndex() - oldPos) != 2) {
// must be 2 digits
return false;
}
min = n.intValue();
if (pos.getIndex() < id.length()) {
if (id.charAt(pos.getIndex()) != 0x003A /*':'*/) {
return false;
}
// [:ss]
pos.setIndex(pos.getIndex() + 1);
oldPos = pos.getIndex();
n = numberFormat.parse(id, pos);
if (pos.getIndex() != id.length()
|| (pos.getIndex() - oldPos) != 2) {
return false;
}
sec = n.intValue();