Example usage for com.google.gwt.i18n.client.impl DateRecord setMonth

List of usage examples for com.google.gwt.i18n.client.impl DateRecord setMonth

Introduction

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

Prototype

@Override
public void setMonth(int month) 

Source Link

Document

Set month field.

Usage

From source file:com.calclab.emite.core.client.xmpp.datetime.gwt.DateTimeFormat.java

License:Open Source License

/**
 * Parses Month field.//w  ww  .j a  v  a2  s  .com
 * 
 * @param text
 *            the time text to be parsed
 * @param pos
 *            Parse position
 * @param cal
 *            DateRecord object that will hold parsed value
 * @param value
 *            numeric value if this field is expressed using numberic
 *            pattern
 * @param start
 *            from where parse start
 * 
 * @return <code>true</code> if parsing successful
 */
private boolean subParseMonth(String text, int[] pos, DateRecord cal, int value, int start) {
    // When month is symbols, i.e., MMM or MMMM, value will be -1.
    if (value < 0) {
        // Want to be able to parse both short and long forms.
        // Try count == 4 first:
        value = matchString(text, start, dateTimeFormatInfo.monthsFull(), pos);
        if (value < 0) { // count == 4 failed, now try count == 3.
            value = matchString(text, start, dateTimeFormatInfo.monthsShort(), pos);
        }
        if (value < 0) {
            return false;
        }
        cal.setMonth(value);
        return true;
    } else if (value > 0) {
        cal.setMonth(value - 1);
        return true;
    }
    return false;
}

From source file:com.calclab.emite.core.client.xmpp.datetime.gwt.DateTimeFormat.java

License:Open Source License

/**
 * Parses a standalone month field./*  w w  w. j av  a  2 s . co m*/
 * 
 * @param text
 *            the time text to be parsed
 * @param pos
 *            Parse position
 * @param cal
 *            DateRecord object that will hold parsed value
 * @param value
 *            numeric value if this field is expressed using numberic
 *            pattern
 * @param start
 *            from where parse start
 * 
 * @return <code>true</code> if parsing successful
 */
private boolean subParseStandaloneMonth(String text, int[] pos, DateRecord cal, int value, int start) {
    // When month is symbols, i.e., LLL or LLLL, value will be -1.
    if (value < 0) {
        // Want to be able to parse both short and long forms.
        // Try count == 4 first:
        value = matchString(text, start, dateTimeFormatInfo.monthsFullStandalone(), pos);
        if (value < 0) { // count == 4 failed, now try count == 3.
            value = matchString(text, start, dateTimeFormatInfo.monthsShortStandalone(), pos);
        }
        if (value < 0) {
            return false;
        }
        cal.setMonth(value);
        return true;
    } else if (value > 0) {
        cal.setMonth(value - 1);
        return true;
    }
    return false;
}