Java Date Parse convertDateForExcel(String timestamp)

Here you can find the source of convertDateForExcel(String timestamp)

Description

Converts the time from FLAME format to Excel-friendly format

License

Open Source License

Parameter

Parameter Description
timestamp A FLAME timestamp string

Exception

Parameter Description
ParseException Invalid timestamp

Return

An Excel-friendly timestamp string

Declaration

public static String convertDateForExcel(String timestamp) throws ParseException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {
    public static final String flameDateFormat = "yyyyMMdd_HHmm_ss";
    public static final String excelDateFormat = "MM/dd/yyyy HH:mm:ss";

    /**/*from w w  w . j a v  a  2  s  .c o  m*/
     * Converts the time from FLAME format to Excel-friendly format
     * @param timestamp         A FLAME timestamp string 
     * @return               An Excel-friendly timestamp string
     * @throws ParseException   Invalid timestamp
     */
    public static String convertDateForExcel(String timestamp) throws ParseException {
        SimpleDateFormat date_format = new SimpleDateFormat(flameDateFormat);
        SimpleDateFormat excel_format = new SimpleDateFormat(excelDateFormat);

        Calendar c = Calendar.getInstance();
        c.setTime(date_format.parse(timestamp));

        return excel_format.format(c.getTime());
    }
}

Related

  1. asDate(String date)
  2. asDate(String param, SimpleDateFormat format)
  3. asDate(String s)
  4. asDate(String string)
  5. asDate(String value, String format)
  6. convertDateFromString(String data)
  7. convertDateStringToDate(String dateString, String format)
  8. convertDateStringToDB(String date)
  9. convertDateStringToMilliseconds(String dateString)