package com.mutouyihao; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Formatter; public class testGoto { public static void main(String[] args){ SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); Date date = new Date(); System.out.println(f.format(date)); try { System.out.println(f.parse("2011-4-21 4:23:32")); } catch (ParseException ex) { // TODO Auto-generated catch block ex.printStackTrace(); } Formatter fmt = new Formatter(); System.out.println( fmt.format("现在时间: %tY-%1$tm-%1$td %1$tI:%1$tM:%1$tS",date)); } }