Java tutorial
//package com.java2s; import java.util.Calendar; public class Main { public static String get_date() { int mYear; int mMonth; int mDay; final Calendar c = Calendar.getInstance(); mYear = c.get(Calendar.YEAR); mMonth = c.get(Calendar.MONTH) + 1; mDay = c.get(Calendar.DAY_OF_MONTH); String result = String.format("%04d-%02d-%02d", mYear, mMonth, mDay); return result; } }