Here you can find the source of todaysDate(int style)
public static String todaysDate(int style) throws Throwable
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/*from www . j a v a 2 s . c o m*/ * Get today's date in various formats * style=0 -> ddMMyyyy * style=1 -> YYYY-MM-dd * style=2 -> dd-MMM-YYY */ public static String todaysDate(int style) throws Throwable { Date date = new Date(); SimpleDateFormat formatterOut = null; // if (style == 0) { formatterOut = new SimpleDateFormat("ddMMMyyyy"); } else if (style == 1) { formatterOut = new SimpleDateFormat("yyyy-MM-dd"); } else if (style == 2) { formatterOut = new SimpleDateFormat("dd-MMM-yyyy"); } else { throw new RuntimeException("Invalid date style"); } return formatterOut.format(date); } }