Java Date to String Date2Str(Date date)

Here you can find the source of Date2Str(Date date)

Description

Date Str

License

Open Source License

Declaration

public static String Date2Str(Date date) 

Method Source Code


//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;
    }
}

Related

  1. convertToString(java.util.Date date)
  2. convertToString(String format, Date date)
  3. date2str(Calendar c)
  4. date2Str(Calendar c, String format)
  5. date2Str(Date aDate)
  6. date2Str(Date date)
  7. date2Str(Date date)
  8. date2Str(Date date, String dateFormat)
  9. date2Str(Date date, String format)