Android examples for java.util:Date Time
get Unix Time String from long
import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.provider.MediaStore; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Calendar; public class Main{ /**//from w w w . j a va 2 s . c o m * ??? ????? ?????. * @param time ??? * @return ?????? ????? ???? */ public static String getTimeString(long time) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(time); String date = "" + c.get(Calendar.YEAR) + "-"; if (c.get(Calendar.MONTH) + 1 >= 10) date += (c.get(Calendar.MONTH) + 1); else date += "0" + (c.get(Calendar.MONTH) + 1); date += "-"; if (c.get(Calendar.DAY_OF_MONTH) >= 10) date += c.get(Calendar.DAY_OF_MONTH); else date += "0" + c.get(Calendar.DAY_OF_MONTH); return date; } }