Android Date to String Convert date2String(int i, int j, int k)

Here you can find the source of date2String(int i, int j, int k)

Description

date String

Declaration

public static String date2String(int i, int j, int k) 

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 ww  .j  a  va 2s .  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. toSimpleDateFormattedString(Date date)
  2. toStringFromDate(Date date)
  3. toUTCFormattedString(Date date)
  4. updateDate(DatePicker picker, Date date)
  5. date2String(Date date, String s)