Java Date String Format dateFormat(String strYear, String strMonth, String strDay)

Here you can find the source of dateFormat(String strYear, String strMonth, String strDay)

Description

date Format

License

Open Source License

Declaration

static public String dateFormat(String strYear, String strMonth, String strDay) 

Method Source Code

//package com.java2s;

public class Main {

    static public String dateFormat(String strYear, String strMonth, String strDay) {
        if (strYear == null || strYear.equals(""))
            return "";
        if (strMonth == null || strMonth.equals(""))
            return "";
        if (strDay == null || strDay.equals(""))
            return "";

        strYear = strYear.trim();// year must be 4 digits.

        strMonth = strMonth.trim();/*w  w w  .j  a v  a2 s  .  c o  m*/
        if (strMonth.length() == 1)
            strMonth = "0" + strMonth;

        strDay = strDay.trim();
        if (strDay.length() == 1)
            strDay = "0" + strDay;

        String strDate = strYear + strMonth + strDay;
        return strDate;
    }
}

Related

  1. dateFormat(String date)
  2. dateFormat(String datetime)
  3. dateFormatFix(String str)
  4. formatDate(byte[] btValue, int iOffset, int iLength)
  5. formatDate(int year, int month, int day)
  6. formatDate(Integer date)