Java Timestamp Format formatTimestampToIndex(java.sql.Timestamp timestamp)

Here you can find the source of formatTimestampToIndex(java.sql.Timestamp timestamp)

Description

formatTimestampToIndex Call this function to format a java.sql.Timestamp into a String with format "yyyyMMddhhmmss" for lucene indexing

License

Open Source License

Parameter

Parameter Description
timestamp Timestamp value representation

Return

String The String format after convertion

Declaration

public static String formatTimestampToIndex(java.sql.Timestamp timestamp) 

Method Source Code

//package com.java2s;
/*//  www  .j av a2 s.c o  m
 * @(#)TextUtility.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */

import java.text.SimpleDateFormat;

public class Main {
    /**
    * formatTimestampToIndex
    *
    * Call this function to format a java.sql.Timestamp into a String
    * with format "yyyyMMddhhmmss" for lucene indexing
    *
    * @param    timestamp  Timestamp value representation
    * @return   String     The String format after convertion
    */
    public static String formatTimestampToIndex(java.sql.Timestamp timestamp) {
        if (timestamp == null) {
            return "";
        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss", java.util.Locale.US);
        String dateStr = sdf.format(timestamp);
        return dateStr;
    }
}

Related

  1. formatTimestamp(Timestamp timestamp, int iType)
  2. formatTimestamp(Timestamp timestamp, String pattern)
  3. formatTimestamp(Timestamp ts, int dateStyle, int timeStyle, Locale locale)
  4. formatTimeStampMsec(long epochTime)
  5. formatTimestampTime(Timestamp ts, boolean colon)
  6. formatTimestampToLong(final String timestampStr)
  7. formatTimestampWithSlashes( java.sql.Timestamp tsZeitpunkt)
  8. formatTimeToString(long timestamp)
  9. formatToLong(String format)