Here you can find the source of convertDate(String date, String sourceFormat, String destinationFormat)
Parameter | Description |
---|---|
date | a parameter |
sourceFormat | a parameter |
destinationFormat | a parameter |
Parameter | Description |
---|
public static String convertDate(String date, String sourceFormat, String destinationFormat) throws java.text.ParseException
//package com.java2s; /**/*from w ww . j ava2 s. co m*/ * Copyright (C) 2010-2014 Think Big Analytics, Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. See accompanying LICENSE file. */ import java.text.SimpleDateFormat; import java.util.*; public class Main { /** * convert the input date from source to destination format * @param date * @param sourceFormat * @param destinationFormat * @return date in the destination format * @throws java.text.ParseException */ public static String convertDate(String date, String sourceFormat, String destinationFormat) throws java.text.ParseException { String returnDateString = ""; SimpleDateFormat formatter = new SimpleDateFormat(sourceFormat); Date returnDate = formatter.parse(date); formatter = new SimpleDateFormat(destinationFormat); returnDateString = formatter.format(returnDate); return returnDateString; } }