Java tutorial
//package com.java2s; import android.support.annotation.NonNull; import java.util.Calendar; public class Main { @NonNull public static String getTime() { Calendar calendar = Calendar.getInstance(); return calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-" + calendar.get(Calendar.DAY_OF_MONTH) + " " + calendar.get(Calendar.HOUR_OF_DAY) + ":" + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND); } }