Code example for MessageFormat

Methods: formatsetFormatByArgumentIndex

0
		} else if (delta < 48 * HOUR) {
			value = "yesterday";
		} else if (delta < 30 * DAY) {
			value = (delta / DAY) + " days ago";
		} 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;
	} 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE