Here you can find the source of parse(String ds)
Parameter | Description |
---|---|
ds | - Date String |
Parameter | Description |
---|---|
Exception | an exception |
public static final Date parse(String ds) throws Exception
//package com.java2s; /**//w w w. j a v a2 s.c o m * Copyright 2012 Subho Ghosh (subho dot ghosh at outlook dot com) * 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. */ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String _DEFAULT_DATE_FORMAT_ = "MM-dd-yyyy HH:mm:ss"; /** * Parse the date string using the default date format. * * @param ds * - Date String * @return * @throws Exception */ public static final Date parse(String ds) throws Exception { return parse(ds, _DEFAULT_DATE_FORMAT_); } /** * Parse the date string using the specified date format. * * @param ds * - Date String * @param format * - Date Format * @return * @throws Exception */ public static final Date parse(String ds, String format) throws Exception { DateFormat formatter = new SimpleDateFormat(format); return (Date) formatter.parse(ds); } }