Here you can find the source of date2String(Date date, String s)
public static String date2String(Date date, String s)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String date2String(int i, int j, int k) { byte byte0 = 10; String s = "0"; String s1 = "-"; StringBuilder stringbuilder = new StringBuilder(); stringbuilder.append(i);/*from w w w .ja va 2 s . com*/ Object obj = "-"; stringbuilder.append(s1); if (++j < byte0) obj = (new StringBuilder(s)).append(j).toString(); else obj = Integer.valueOf(j); stringbuilder.append(obj); obj = "-"; stringbuilder.append(s1); if (k < byte0) obj = (new StringBuilder(s)).append(k).toString(); else obj = Integer.valueOf(k); stringbuilder.append(obj); return stringbuilder.toString(); } public static String date2String(Date date, String s) { Object obj = 0; try { String s1 = stringNull(s); obj = (new SimpleDateFormat(s1)).format(date); } catch (Exception exception) { } return ((String) (obj)); } public static String stringNull(String s) { if (s != null) { s = s.trim(); if (s.equals("") || s.equalsIgnoreCase("null")) s = ""; } return s; } }