Java Day getDayDate(String date, String formatFormat)

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

Description

get Day Date

License

Open Source License

Declaration

public static Date getDayDate(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 getDayDate(String date, String formatFormat) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(strToDate(date, formatFormat));
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        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. getDayAfter(String dateformat, String day, int filed, int delta)
  2. getDayAfterTommorrowsDateFne()
  3. getDayBefore(Date date)
  4. getDayBegin(Date date)
  5. getDayBetween(String firstDay, String secondDay)
  6. getDayDesc(Date arg)
  7. getDayEnd(Date date)
  8. getDayEndTime(int off, String timezone)
  9. getDayForDate(String dateToCheck, String pattern)