Example usage for com.google.gwt.i18n.shared.impl DateRecord setHours

List of usage examples for com.google.gwt.i18n.shared.impl DateRecord setHours

Introduction

In this page you can find the example usage for com.google.gwt.i18n.shared.impl DateRecord setHours.

Prototype

@Override
public void setHours(int hours) 

Source Link

Document

Set hour field.

Usage

From source file:com.rnb.plategka.shared.DateTimeFormat.java

License:Apache License

/**
 * Converts one field of the input string into a numeric field value.
 * Returns <code>false</code> if failed.
 * //ww  w  . j  ava  2  s . co m
 * @param text
 *            the time text to be parsed
 * @param pos
 *            Parse position
 * @param part
 *            the pattern part for this field
 * @param digitCount
 *            when greater than 0, numeric parsing must obey the count
 * @param cal
 *            DateRecord object that will hold parsed value
 * 
 * @return <code>true</code> if parsing successful
 */
@SuppressWarnings("fallthrough")
private boolean subParse(String text, int[] pos, PatternPart part, int digitCount, DateRecord cal) {

    skipSpace(text, pos);

    int start = pos[0];
    char ch = part.text.charAt(0);

    // Parse integer value if it is a numeric field.
    int value = -1; // initialize value to be -1,
    if (isNumeric(part)) {
        if (digitCount > 0) {
            if ((start + digitCount) > text.length()) {
                return false;
            }
            value = parseInt(text.substring(0, start + digitCount), pos);
        } else {
            value = parseInt(text, pos);
        }
    }

    switch (ch) {
    case 'G': // era
        value = matchString(text, start, dateTimeFormatInfo.erasFull(), pos);
        cal.setEra(value);
        return true;
    case 'M': // month
        return subParseMonth(text, pos, cal, value, start);
    case 'L': // standalone month
        return subParseStandaloneMonth(text, pos, cal, value, start);
    case 'E': // day of week
        return subParseDayOfWeek(text, pos, start, cal);
    case 'c': // standalone day of week
        return subParseStandaloneDay(text, pos, start, cal);
    case 'a': // AM/PM
        value = matchString(text, start, dateTimeFormatInfo.ampms(), pos);
        cal.setAmpm(value);
        return true;
    case 'y': // year
        return subParseYear(text, pos, start, value, part, cal);
    case 'd': // day of month
        if (value <= 0) {
            return false;
        }
        cal.setDayOfMonth(value);
        return true;
    case 'S': // fractional seconds
        if (value < 0) {
            return false;
        }
        return subParseFractionalSeconds(value, start, pos[0], cal);
    case 'h': // hour (1..12)
        if (value == 12) {
            value = 0;
        }
        // fall through
    case 'K': // hour (0..11)
    case 'H': // hour (0..23)
        if (value < 0) {
            return false;
        }
        cal.setHours(value);
        return true;
    case 'k': // hour (1..24)
        if (value < 0) {
            return false;
        }
        cal.setHours(value);
        return true;
    case 'm': // minute
        if (value < 0) {
            return false;
        }
        cal.setMinutes(value);
        return true;
    case 's': // second
        if (value < 0) {
            return false;
        }
        cal.setSeconds(value);
        return true;

    case 'z': // time zone offset
    case 'Z': // time zone RFC
    case 'v': // time zone generic
        return subParseTimeZoneInGMT(text, start, pos, cal);
    default:
        return false;
    }
}