Here you can find the source of formatDate(String date)
Parameter | Description |
---|---|
date | the date |
public static String formatDate(String date)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/*from ww w . j ava2 s.co m*/ * Format date. * * @param date * the date * @return the string */ public static String formatDate(Date date) { SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); return sd.format(date); } /** * Format date. * * @param date * the date * @return the string */ public static String formatDate(String date) { /* Function to change the date format from mm-dd-yy to yy-mm-dd*/ String invDt1[] = date.toString().split("-"); String invDt = invDt1[2] + "-" + invDt1[1] + "-" + invDt1[0]; System.out.println("<<<<date>>>> " + invDt); return invDt; } }