Java Minute Get getMinuteDate(String date, String formatFormat)

Here you can find the source of getMinuteDate(String date, String formatFormat)

Description

get Minute Date

License

Open Source License

Declaration

public static Date getMinuteDate(String date, String formatFormat) 

Method Source Code


//package com.java2s;
/*/*from  w w  w. j av  a  2s .c o m*/
 * Copyright 1998-2012 360buy.com All right reserved. This software is the confidential and proprietary information of
 * 360buy.com ("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 360buy.com.
 */

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

public class Main {

    public static Date getMinuteDate(String date, String formatFormat) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(strToDate(date, formatFormat));
        cal.set(Calendar.SECOND, 0);
        return cal.getTime();
    }

    public static Date strToDate(String dateStr, String formatStr) {
        Date date = null;
        if (dateStr != null && !"".equals(dateStr)) {
            SimpleDateFormat sdf = new SimpleDateFormat(formatStr);
            try {
                date = sdf.parse(dateStr);
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        return date;
    }
}

Related

  1. getMinute(long time)
  2. getMinute(String time)
  3. getMinuteAfter(Date date, int minute)
  4. getMinuteAsInt(String hourString)
  5. getMinuteCa(Date d1, Date d2)
  6. getMinuteFromHMS(String hms)
  7. getMinuteFromMilliSecond(int milliSecond)
  8. getMinuteFromTime(Long timeInMilliseconds)
  9. getMinuteInt(long time)