Search in sources :

Example 21 with FieldPosition

use of java.text.FieldPosition in project j2objc by google.

the class FieldPositionTest method test_ConstructorLjava_text_Format$FieldI.

/**
	 * @tests java.text.FieldPosition#FieldPosition(java.text.Format$Field, int)
	 */
public void test_ConstructorLjava_text_Format$FieldI() {
    // Test for constructor java.text.FieldPosition(Format.Field, int)
    FieldPosition fpos = new FieldPosition(DateFormat.Field.MONTH, DateFormat.MONTH_FIELD);
    assertSame("Constructor failed to set field attribute!", DateFormat.Field.MONTH, fpos.getFieldAttribute());
    assertEquals("Test1: Constructor failed to set field identifier!", DateFormat.MONTH_FIELD, fpos.getField());
    // test special cases
    FieldPosition fpos2 = new FieldPosition(DateFormat.Field.HOUR1, DateFormat.HOUR1_FIELD);
    assertSame("Constructor failed to set field attribute!", DateFormat.Field.HOUR1, fpos2.getFieldAttribute());
    assertEquals("Test2: Constructor failed to set field identifier!", DateFormat.HOUR1_FIELD, fpos2.getField());
    FieldPosition fpos3 = new FieldPosition(DateFormat.Field.TIME_ZONE, DateFormat.MONTH_FIELD);
    assertSame("Constructor failed to set field attribute!", DateFormat.Field.TIME_ZONE, fpos3.getFieldAttribute());
    assertEquals("Test3: Constructor failed to set field identifier!", DateFormat.MONTH_FIELD, fpos3.getField());
}
Also used : FieldPosition(java.text.FieldPosition)

Example 22 with FieldPosition

use of java.text.FieldPosition in project tdi-studio-se by Talend.

the class BusinessStructuralFeatureParser method getStringByPattern.

/**
     * @generated
     */
protected String getStringByPattern(IAdaptable adapter, int flags, String pattern, MessageFormat processor) {
    EObject element = (EObject) adapter.getAdapter(EObject.class);
    Object value = element.eGet(feature);
    value = getValidValue(feature, value);
    return processor.format(new Object[] { value }, new StringBuffer(), new FieldPosition(0)).toString();
}
Also used : EObject(org.eclipse.emf.ecore.EObject) EObject(org.eclipse.emf.ecore.EObject) FieldPosition(java.text.FieldPosition)

Example 23 with FieldPosition

use of java.text.FieldPosition in project tdi-studio-se by Talend.

the class BusinessStructuralFeaturesParser method getStringByPattern.

/**
     * @generated
     */
protected String getStringByPattern(IAdaptable adapter, int flags, String pattern, MessageFormat processor) {
    EObject element = (EObject) adapter.getAdapter(EObject.class);
    List values = new ArrayList(features.size());
    for (Iterator it = features.iterator(); it.hasNext(); ) {
        EStructuralFeature feature = (EStructuralFeature) it.next();
        Object value = element.eGet(feature);
        value = getValidValue(feature, value);
        values.add(value);
    }
    return processor.format(values.toArray(new Object[values.size()]), new StringBuffer(), new FieldPosition(0)).toString();
}
Also used : EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) ArrayList(java.util.ArrayList) List(java.util.List) EObject(org.eclipse.emf.ecore.EObject) FieldPosition(java.text.FieldPosition)

Example 24 with FieldPosition

use of java.text.FieldPosition in project atmosphere by Atmosphere.

the class CookieUtil method toString.

public static String toString(Cookie c) {
    StringBuffer buf = new StringBuffer();
    // Servlet implementation checks name
    buf.append(c.getName());
    buf.append("=");
    // Servlet implementation does not check anything else
    /*
         * The spec allows some latitude on when to send the version attribute
         * with a Set-Cookie header. To be nice to clients, we'll make sure the
         * version attribute is first. That means checking the various things
         * that can cause us to switch to a v1 cookie first.
         *
         * Note that by checking for tokens we will also throw an exception if a
         * control character is encountered.
         */
    // Start by using the version we were asked for
    int newVersion = c.getVersion();
    // Now build the cookie header
    // Value
    maybeQuote(buf, c.getValue());
    // Add version 1 specific information
    if (newVersion == 1) {
        // Version=1 ... required
        buf.append("; Version=1");
        // Comment=comment
        if (c.getComment() != null) {
            buf.append("; Comment=");
            maybeQuote(buf, c.getComment());
        }
    }
    // Add domain information, if present
    if (c.getDomain() != null) {
        buf.append("; Domain=");
        maybeQuote(buf, c.getDomain());
    }
    // Max-Age=secs ... or use old "Expires" format
    if (c.getMaxAge() >= 0) {
        if (newVersion > 0) {
            buf.append("; Max-Age=");
            buf.append(c.getMaxAge());
        }
        if (newVersion == 0) {
            // Wdy, DD-Mon-YY HH:MM:SS GMT ( Expires Netscape format )
            buf.append("; Expires=");
            // To expire immediately we need to set the time in past
            if (c.getMaxAge() == 0) {
                buf.append(ancientDate);
            } else {
                DateFormat df = new SimpleDateFormat(OLD_COOKIE_PATTERN, Locale.US);
                df.setTimeZone(TimeZone.getTimeZone("GMT"));
                df.format(new Date(System.currentTimeMillis() + c.getMaxAge() * 1000L), buf, new FieldPosition(0));
            }
        }
    }
    // Path=path
    if (c.getPath() != null) {
        buf.append("; Path=");
        maybeQuote(buf, c.getPath());
    }
    // Secure
    if (c.getSecure()) {
        buf.append("; Secure");
    }
    // HttpOnly
    if (c.isHttpOnly()) {
        buf.append("; HttpOnly");
    }
    return buf.toString();
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) FieldPosition(java.text.FieldPosition) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 25 with FieldPosition

use of java.text.FieldPosition in project otapij by FellowTraveler.

the class DatePicker method formatDateText.

/**
     * Returns a short string representation of the specified date (January, 2001).
     * @param dt
     * @return short string
     */
private static String formatDateText(final Date dt) {
    final DateFormat df = DateFormat.getDateInstance(DateFormat.LONG);
    final StringBuffer mm = new StringBuffer();
    final StringBuffer yy = new StringBuffer();
    final FieldPosition mmfp = new FieldPosition(DateFormat.MONTH_FIELD);
    final FieldPosition yyfp = new FieldPosition(DateFormat.YEAR_FIELD);
    df.format(dt, mm, mmfp);
    df.format(dt, yy, yyfp);
    return (mm.toString().substring(mmfp.getBeginIndex(), mmfp.getEndIndex()) + " " + yy.toString().substring(yyfp.getBeginIndex(), yyfp.getEndIndex()));
}
Also used : DateFormat(java.text.DateFormat) FieldPosition(java.text.FieldPosition)

Aggregations

FieldPosition (java.text.FieldPosition)60 Date (java.util.Date)18 SimpleDateFormat (java.text.SimpleDateFormat)15 IsoDateFormat (alma.acs.util.IsoDateFormat)9 DecimalFormat (java.text.DecimalFormat)9 ILogEntry (com.cosylab.logging.engine.log.ILogEntry)8 ACSLogParser (alma.acs.logging.engine.parser.ACSLogParser)5 MessageFormat (java.text.MessageFormat)5 DateFormat (java.text.DateFormat)4 NumberFormat (java.text.NumberFormat)3 ParsePosition (java.text.ParsePosition)3 Vector (java.util.Vector)3 LogTypeHelper (com.cosylab.logging.engine.log.LogTypeHelper)2 ChoiceFormat (java.text.ChoiceFormat)2 ParseException (java.text.ParseException)2 Calendar (java.util.Calendar)2 GregorianCalendar (java.util.GregorianCalendar)2 List (java.util.List)2 Random (java.util.Random)2 EObject (org.eclipse.emf.ecore.EObject)2