Here you can find the source of toDateStyleBoth(String dateStr)
public static Date toDateStyleBoth(String dateStr)
//package com.java2s; //License from project: LGPL import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date toDateStyleBoth(String dateStr) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try {/* w w w . j a v a 2 s.c o m*/ return sdf.parse(dateStr); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } public static String toDateStyleBoth(Date dateStr) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(dateStr); } }