Java Minute Calculate getCurrCustomMinuteDate(String formatStr, int changeMinute)

Here you can find the source of getCurrCustomMinuteDate(String formatStr, int changeMinute)

Description

get Curr Custom Minute Date

License

Open Source License

Declaration

public static String getCurrCustomMinuteDate(String formatStr, int changeMinute) 

Method Source Code

//package com.java2s;
/*//from w  w w .  jav  a2 s  .co  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.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {

    public static String getCurrCustomMinuteDate(String formatStr, int changeMinute) {
        Calendar cal = new GregorianCalendar();
        cal.setTime(getCurrDate());
        cal.add(Calendar.MINUTE, changeMinute);
        return dateToStr(cal.getTime(), formatStr);
    }

    public static Date getCurrDate() {
        return new Date();
    }

    public static String getCurrDate(String formatStr) {
        return dateToStr(getCurrDate(), formatStr);
    }

    public static String dateToStr(Date date, String formatStr) {
        String result = null;
        if (date != null) {
            SimpleDateFormat sdf = new SimpleDateFormat(formatStr);
            result = sdf.format(date);
        }
        return result;
    }
}

Related

  1. compareDateEndWithMinute(Date d1, Date d2)
  2. countTimeAfter(String date, int minute)
  3. diffOfMinutes(String begin, String end)
  4. formatDateMinutes(Date myDate, String pattern)
  5. getAlarmMinutes(String dtStart, String dtAlarm, Logger logger)
  6. getForwardTimeByMinute(int minute, String format)
  7. getFutureDate(int _minutes)
  8. getIntevalMinutes(String startDate, String endDate)
  9. getTime(int minuteDelt)