Code example for MessageFormat

Methods: format, setFormatByArgumentIndex

0
			value = "yesterday";
		} else if (delta < 30 * DAY) {
			MessageFormat mf = new MessageFormat("{0} days ago");
			value = mf.format(new Object[] { delta / DAY });
		} else if (delta < 12 * MONTH) {
			MessageFormat form = new MessageFormat("{0}");
			Object[] formArgs = new Object[] { delta / MONTH };
			double[] tweetLimits = {1,2};
			String[] tweetPart = { "one month ago", "{0} months ago" };
			ChoiceFormat tweetForm = new ChoiceFormat(tweetLimits, tweetPart);
			form.setFormatByArgumentIndex(0, tweetForm);
			value = form.format(formArgs);
		} 
		return value;
	} 
 
	/** 
	 * Returns the relative time passed since now. 
	 *  
	 * @return String 
	 */