Android examples for java.util:Date Format
Format date to Hyphenated String
import java.util.Calendar; import android.text.format.DateFormat; public class Main { public static String toHyphenatedString(int year, int monthOfYear, int day) { Calendar calendar = Calendar.getInstance(); calendar.set(year, monthOfYear, day); return DateFormat.format("yyyy-MM-dd", calendar).toString(); }// www . ja v a 2 s . c o m }