Here you can find the source of getMessageForDistance(long distance)
public static final String getMessageForDistance(long distance)
//package com.java2s; import java.text.MessageFormat; public class Main { private static final String pattern = "{0} {1} {2}"; private static final String DAYS = "days"; private static final String AWAY = "to go"; private static final String PAST = "past"; private static final String TODAY = "Today"; private static final String TOMORROW = "Tomorrow"; private static final String YESTERDAY = "Yesterday"; public static final String getMessageForDistance(long distance) { if (distance == 0) return TODAY; if (distance == 1) return TOMORROW; if (distance == -1) return YESTERDAY; String pastOrFuture = distance > 0 ? AWAY : PAST; distance = distance < 0 ? distance * -1 : distance; String message = MessageFormat.format(pattern, new Object[] { distance, DAYS, pastOrFuture }); return message; }//from w w w . ja v a 2 s . co m }