Here you can find the source of Date2Str(Date date)
public static String Date2Str(Date date)
//package com.java2s; /*/*from ww w . j a v a2 s . c o m*/ * K4M, License, Version 1.1 * * Copyright (c) 2000 K4M. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are prohibited. */ import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String Date2Str(Date date) { String str = null; try { str = new SimpleDateFormat("yyyy/MM/dd,HH:mm:ss").format(date); } catch (Exception e) { } return str; } public static String Date2Str(Date date, String pattern) { String str = null; try { str = new SimpleDateFormat(pattern).format(date); } catch (Exception e) { } return str; } public static String Date2Str(long date, String pattern) { String str = null; try { str = (String) new SimpleDateFormat(pattern).format(new Date(date)); } catch (Throwable e) { } return str; } }