提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用SimpleDateFormat格式化分钟
import java.text.SimpleDateFormat;/*来 自 时代Java - nowjava.com*/ import java.util.Date; public class Main { public static void main(String[] args) { Date date = new Date(); //formatting minute in m format like 1,2 etc. String strDateFormat = "m"; SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat); System.out.println("minutes in m format : " + sdf.format(date)); //formatting minutes in mm format like 01, 02 etc. strDateFormat = "mm"; sdf = new