Java Timestamp Convert To toMediaWikiString(Timestamp timestamp)

Here you can find the source of toMediaWikiString(Timestamp timestamp)

Description

to Media Wiki String

License

Open Source License

Declaration

public static String toMediaWikiString(Timestamp timestamp) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 Torsten Zesch./*from   ww w .j av a  2s .c o  m*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v3
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl.html
 * 
 * Contributors:
 *     Torsten Zesch - initial API and implementation
 ******************************************************************************/

import java.sql.Timestamp;

public class Main {
    public static String toMediaWikiString(Timestamp timestamp) {
        String original = timestamp.toString();
        StringBuffer result = new StringBuffer();
        result.append(original.substring(0, 4));//year
        result.append(original.substring(5, 7));//month
        result.append(original.substring(8, 10));//date
        result.append(original.substring(11, 13));//hour
        result.append(original.substring(14, 16));//minute
        result.append(original.substring(17, 19));//second
        return result.toString();
    }
}

Related

  1. toFormatedString(final Timestamp ts, final String timeZoneId)
  2. toGmtTimestampString(Timestamp timestamp)
  3. toInstant(final Timestamp timestamp)
  4. toJavaDate(Timestamp dt)
  5. toLocalDateTime(Timestamp timestamp)