Java Date String Format formatDate(String date)

Here you can find the source of formatDate(String date)

Description

format Date

License

Open Source License

Declaration

public static String formatDate(String date) 

Method Source Code

//package com.java2s;
/*//from   www  .j a v a2 s  .  c om
 * OAI4Solr exposes your Solr indexes by adding a OAI2 protocol handler.
 *
 *     Copyright (C) 2011  International Institute of Social History
 *
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    public static String formatDate(String date) {

        final String template = "2010-01-01T00:00:00Z";
        final int tl = template.length();
        final int dl = date.length();
        if (dl > tl)
            return date.substring(0, tl - 1) + "Z"; // Not entirely correct... GMT correction needed.
        else if (dl < tl)
            return date + template.substring(dl);
        return date;
    }
}

Related

  1. formatDate(byte[] btValue, int iOffset, int iLength)
  2. formatDate(int year, int month, int day)
  3. formatDate(Integer date)
  4. formatDate(Integer day, Integer month, Integer year)
  5. FormatDate(String aDate)
  6. formatDate(String date)
  7. formatDate(String date)
  8. formatDate(String date)
  9. formatDate(String date, int format)