Here you can find the source of getDatetime(String value)
Parameter | Description |
---|---|
value | the value. May be null |
public static Date getDatetime(String value)
//package com.java2s; /*// ww w . jav a 2 s . c o m * Version: 1.0 * * The contents of this file are subject to the OpenVPMS License Version * 1.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.openvpms.org/license/ * * Software distributed under the License is distributed on an 'AS IS' basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * Copyright 2015 (C) OpenVPMS Ltd. All Rights Reserved. */ import java.sql.Timestamp; import java.util.Date; public class Main { /** * Helper to create a date-time given a string of the form * <em>yyyy-mm-dd hh:mm:ss</em>. * * @param value the value. May be {@code null} * @return the corresponding date-time or {@code null} if {@code value} is null */ public static Date getDatetime(String value) { return value != null ? new Date(Timestamp.valueOf(value).getTime()) : null; // use Date, for easy comparison } }