Java Date Format Change convertTimeStringToTimestamp(String timeString, String timeFormat)

Here you can find the source of convertTimeStringToTimestamp(String timeString, String timeFormat)

Description

convert Time String To Timestamp

License

Apache License

Declaration

public static long convertTimeStringToTimestamp(String timeString,
            String timeFormat) throws ParseException 

Method Source Code

//package com.java2s;
/*/*from  w ww .j ava  2s  . c o m*/
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */

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

public class Main {
    public static long convertTimeStringToTimestamp(String timeString,
            String timeFormat) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat(timeFormat);
        return sdf.parse(timeString).getTime();
    }
}

Related

  1. convertDateStringToString(String strDate, String currentFormat, String parseFormat)
  2. convertDatetimeFormat(Date tar_date, String date_format)
  3. convertIso8601FormatToArsTime(String timeString)
  4. convertIso8601FormatToArsTimeOfDay(String timeOfDayString)
  5. convertISO8610ToCalendar(String iso8601string)