Here you can find the source of toDateTimeFormat(String input, String inputfmt, String outputfmt)
public static String toDateTimeFormat(String input, String inputfmt, String outputfmt)
//package com.java2s; /*//from w w w. j a va2 s. c om * Copyright (C) 2014-2016 LinkedIn Corp. 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. */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String toDateTimeFormat(String input, String inputfmt, String outputfmt) { Date date = null; SimpleDateFormat infmt = new SimpleDateFormat(inputfmt); try { date = infmt.parse(input); } catch (ParseException e) { e.printStackTrace(); } SimpleDateFormat outFormat = new SimpleDateFormat(outputfmt); return outFormat.format(date); } }