Java Today getTodayWithTime(final String iTime)

Here you can find the source of getTodayWithTime(final String iTime)

Description

get Today With Time

License

Apache License

Declaration

public static Date getTodayWithTime(final String iTime)
            throws ParseException 

Method Source Code

//package com.java2s;
/*//from w w w  .j av  a  2  s .c  o m
 *
 *  *  Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.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.
 *  *
 *  * For more information: http://www.orientechnologies.com
 *
 */

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static final long SECOND = 1000;
    public static final long MINUTE = SECOND * 60;

    public static Date getTodayWithTime(final String iTime)
            throws ParseException {
        final SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
        Calendar calParsed = Calendar.getInstance();
        calParsed.setTime(df.parse(iTime));
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.HOUR_OF_DAY, calParsed.get(Calendar.HOUR_OF_DAY));
        cal.set(Calendar.MINUTE, calParsed.get(Calendar.MINUTE));
        cal.set(Calendar.SECOND, calParsed.get(Calendar.SECOND));
        cal.set(Calendar.MILLISECOND, 0);
        return cal.getTime();
    }
}

Related

  1. getTodayString()
  2. getTodayString()
  3. getTodayString()
  4. getTodayTime()
  5. getTodayTimeForDB()
  6. getTodayYmd()
  7. getTodayYMD()
  8. getTodayZero()
  9. getTodayZero()