Java String to Time getTime(String dateTimeString)

Here you can find the source of getTime(String dateTimeString)

Description

get Time

License

Open Source License

Declaration

public static long getTime(String dateTimeString) 

Method Source Code

//package com.java2s;
/**//w  ww. j  a  v a2s .  c o m
 * Created on Aug 9, 2004
 *
 * Copyright 2005 by Arysys Technologies (P) Ltd.,
 * #3,Shop line,
 * Sasmira Marg,
 * Worli,Mumbai 400 025
 * India
 *
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of Arysys Technologies (P) Ltd. ("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 Arysys Technologies (P) Ltd.
 *
 */

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static long getTime(String dateTimeString) {
        long time = 0;
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = sdf.parse(dateTimeString);
            time = date.getTime();
        } catch (Exception e) {
            e.printStackTrace();
            time = 0;
        }
        return time;
    }
}

Related

  1. getSignTime(final String stStr)
  2. getStringWithTime(String str)
  3. getSystemTime(String pattern)
  4. getTime(String date)
  5. getTime(String date, String pattern)
  6. getTime(String file)
  7. getTime(String parrten)
  8. getTime(String pattern)
  9. getTime(String pattern)