Here you can find the source of formatterDate(Date date, byte format)
Parameter | Description |
---|---|
date | a parameter |
public static String formatterDate(Date date, byte format)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/*from ww w . j a va 2 s . c o m*/ * This method formats a date using the Brazilian convention * * @param date * @return formatted date */ public static String formatterDate(Date date, byte format) { // checking date if (date == null) { return ""; } // creating simple date formatter instance SimpleDateFormat simpleDateFormat; switch (format) { case 1: simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); break; case 2: simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy"); break; default: simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); break; } // formatting date String formattedDate = simpleDateFormat.format(date); // return formatted date return formattedDate; } }