use of com.squarespace.template.MessageFormats in project template-compiler by Squarespace.
the class MessageFormatsTest method testInterval.
@Test
public void testInterval() {
String actual;
CLDR cldr = CLDR.get("en");
MessageFormats formats = new MessageFormats(cldr);
formats.setTimeZone("America/New_York");
String message = "{0;1 datetime-interval}";
long epoch = 1582129775000L;
long extra = 86400000 + 3600000;
MessageArgs args = args().add(new LongNode(epoch)).add(new LongNode(epoch + extra));
actual = formats.formatter().format(message, args);
assertEquals(actual, "Feb 19 – 20, 2020");
}
use of com.squarespace.template.MessageFormats in project template-compiler by Squarespace.
the class MessageFormatsTest method testCurrency.
@Test
public void testCurrency() {
String actual;
CLDR cldr = CLDR.get("en");
MessageFormats formats = new MessageFormats(cldr);
formats.setTimeZone("America/New_York");
String message = "{0 currency style:standard}";
ObjectNode money = money("12345.789", "USD");
actual = formats.formatter().format(message, args().add(money));
assertEquals(actual, "$12,345.79");
money = newmoney("12345.789", "USD");
actual = formats.formatter().format(message, args().add(money));
assertEquals(actual, "$12,345.79");
}
Aggregations