Here you can find the source of dateParser(Date date)
public static String dateParser(Date date)
//package com.java2s; /**// w w w . ja v a 2s . c o m * Copyright (c) Vietsoftware, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String dateParser(Date date) { if (date == null) { return ""; } Calendar cal = Calendar.getInstance(); String dateStr = ""; cal.setTime(date); int day = cal.get(Calendar.DAY_OF_MONTH); int month = cal.get(Calendar.MONTH) + 1; int year = cal.get(Calendar.YEAR); dateStr = day + "/" + month + "/" + year; return dateStr; } /** * Ham chuyen 1 xau sang ngay thang<br /> * Copied from com.vportal.portlet.edirectory.util.EDirectoryUtil * * @param date * Xau chua ngay thang, co dang: dd/MM/yyyy * @return Doi tuong ngay thang */ public static Date dateParser(String date) { try { SimpleDateFormat result = new SimpleDateFormat("dd/MM/yyyy"); Date newDate = result.parse(date); return newDate; } catch (Exception e) { e.printStackTrace(); } return null; } }