Java Parse Time parseTime(String time, String formatStrBefore, String formatStrAfter)

Here you can find the source of parseTime(String time, String formatStrBefore, String formatStrAfter)

Description

parse Time

License

Open Source License

Declaration

public static String parseTime(String time, String formatStrBefore, String formatStrAfter)
        throws ParseException 

Method Source Code

//package com.java2s;
/**//from  www .jav  a 2 s.  co m
 * Project: szs-demo
 * 
 * File Created at 2016?8?19?
 * chiukong
 * 
 * Copyright 2015 Dafy Finance Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Dafy Finance Company. ("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 http://www.dafy.com.
 */

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static String parseTime(String time, String formatStrBefore, String formatStrAfter)
            throws ParseException {
        SimpleDateFormat bfSp = new SimpleDateFormat(formatStrBefore);
        SimpleDateFormat afSp = new SimpleDateFormat(formatStrAfter);
        return afSp.format(bfSp.parse(time));
    }

    public static String parseTime(Date time, String formatStrAfter) throws ParseException {
        SimpleDateFormat afSp = new SimpleDateFormat(formatStrAfter);
        return afSp.format(time);
    }
}

Related

  1. parseTime(String str)
  2. parseTime(String t)
  3. parseTime(String text)
  4. parseTime(String time)
  5. parseTime(String time)
  6. parseTime(String timestring)
  7. parseTime(String timeString, TimeZone timeZone)
  8. parseTime(String token)
  9. parseTimeConfiguration(String time)