Java examples for java.util:Date Format
to Standard Date String in format yyyy-MM-dd HH:mm:ss
/*//from w ww . j a va2s .c o m * https://github.com/EngleVV/MyRepository * Copyright (c) 2004-2015 All Rights Reserved. */ //package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; public class Main { public static void main(String[] argv) throws Exception { Calendar calendar = Calendar.getInstance(); System.out.println(toStandardDateString(calendar)); } public static String toStandardDateString(Calendar calendar) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss", Locale.CHINA); return simpleDateFormat.format(calendar.getTime()); } public static String toStandardDateString(Date date) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss", Locale.CHINA); return simpleDateFormat.format(date); } }