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());
}
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();
}
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();
}
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();
}
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()));
}
Aggregations