Here you can find the source of createDateString(long startDate, long endDate)
public static String createDateString(long startDate, long endDate)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Formatter; import java.util.GregorianCalendar; import java.util.Locale; import java.util.TimeZone; public class Main { public static String createDateString(long startDate, long endDate) { GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance(TimeZone.getDefault()); StringBuffer dateLine = new StringBuffer(50); Formatter formatter = new Formatter(dateLine, Locale.ENGLISH); cal.setTimeInMillis(startDate);/*w w w.jav a 2 s . com*/ dateLine.append("From "); formatter.format("%1$tH:%1$tM (GMT) %1$tb %1$te,%1$tY", cal); cal.setTimeInMillis(endDate); dateLine.append(" to "); formatter.format("%1$tH:%1$tM (GMT) %1$tb %1$te,%1$tY", cal); return dateLine.toString(); } }