Here you can find the source of getCurrentDataInFormat(String pattern)
public static String getCurrentDataInFormat(String pattern)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; public class Main { public static String getCurrentDataInFormat(String pattern) { return getOffsetDateInFormat(0, pattern); }//from w ww . ja va2 s. com public static String getOffsetDateInFormat(int offsetDay, String pattern) { DateFormat dateFormat = new SimpleDateFormat(pattern); Calendar cal = Calendar.getInstance(); if (offsetDay != 0) { cal.add(Calendar.DATE, offsetDay); } return dateFormat.format(cal.getTime()); } }