Java Utililty Methods Minute Calculate

List of utility methods to do Minute Calculate

Description

The list of methods to do Minute Calculate are organized into topic(s).

Method

longgetTime(int minuteDelt)
get Time
return (new Date().getTime() + minuteDelt * 60000) / 1000;
StringgetTimeAddMinute(String time, int minute)
get Time Add Minute
ca.setTime(stdt(time));
ca.add(Calendar.MINUTE, minute);
return dtts(ca.getTime());
StringgetTimeInDate(int offSetInMinutes)
get Time In Date
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
Date dNow = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(dNow);
calendar.add(Calendar.MINUTE, offSetInMinutes);
dNow = calendar.getTime();
return dateFormat.format(dNow);
StringgetTravelTimeinMinutes(String startTime, String endTime)
Calculates difference in minutes between two datetimes
int diffMinutes = 0;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
Date startDate = null, endDate = null;
try {
    startDate = dateFormat.parse(startTime);
    endDate = dateFormat.parse(endTime);
    Calendar calStart = Calendar.getInstance();
    calStart.setTime(startDate);
...
StringminusMinutes(String s, long minutes)
minus Minutes
if (!s.contains(" "))
    throw new Exception();
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(s);
long time = date.getTime() - (minutes * 10000L);
date.setTime(time);
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
return sf.format(date);
intminuteBetween(Date smdate, Date bdate)
minute Between
Calendar cal = Calendar.getInstance();
cal.setTime(smdate);
long time1 = cal.getTimeInMillis();
cal.setTime(bdate);
long time2 = cal.getTimeInMillis();
long between_days = (time2 - time1) / (1000 * 60);
return Integer.parseInt(String.valueOf(between_days));
intminutesBetween(String from, String to, String format)
minutes Between
SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.UK);
Calendar calendar = Calendar.getInstance(Locale.UK);
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.setMinimalDaysInFirstWeek(4);
Date date1 = null;
Date date2 = null;
try {
    date1 = formatter.parse(from);
...
StringminutesToHylaTime(int mins)
minutes To Hyla Time
String result;
DecimalFormat fmt = new DecimalFormat("00");
result = fmt.format(mins % 60);
mins /= 60;
result = fmt.format(mins % 24) + result;
mins /= 24;
result = fmt.format(mins) + result;
return result;
...
DateplusMinute(Date date, int minutes)
plus Minute
if (date == null)
    date = getToday();
return changeMinute(date, minutes);
DateplusMinute(int minute)
plus Minute
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MINUTE, minute);
return cal.getTime();