Android Date to String Convert date2String(Date date, String s)

Here you can find the source of date2String(Date date, String s)

Description

date String

Declaration

public static String date2String(Date date, String s) 

Method Source Code

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

Related

  1. convertDateToString(Date date)
  2. toSimpleDateFormattedString(Date date)
  3. toStringFromDate(Date date)
  4. toUTCFormattedString(Date date)
  5. updateDate(DatePicker picker, Date date)
  6. date2String(int i, int j, int k)