Java tutorial
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static String getCurrentTime() { Long currentTimeMillis = System.currentTimeMillis(); return formatCurrentTime(currentTimeMillis); } private static String formatCurrentTime(long currentTimeMillis) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.CHINA); Date currentDate = new Date(currentTimeMillis); return simpleDateFormat.format(currentDate); } }