Java Utililty Methods Day of

List of utility methods to do Day of

Description

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

Method

StringminusDate(int day, int type)
return Minus day to date strings with user defined format.
GregorianCalendar cal = new GregorianCalendar();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
cal.add(Calendar.DAY_OF_MONTH, -1);
cal.add(type, -day);
return formatter.format(cal.getTime());
DatenextDay(Date date)
next Day
Date newDate = (Date) date.clone();
long time = newDate.getTime() / 1000L + 86400L;
newDate.setTime(time * 1000L);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
    newDate = format.parse(format.format(newDate));
} catch (Exception ex) {
    System.out.println(ex.getMessage());
...
StringnowDayString()
now Day String
return dayDateFormat.format(dateTimeConvert(0));
DateparseBirthday(String r)
parse Birthday
SimpleDateFormat df = new SimpleDateFormat("y-M-d");
return df.parse(r);
CalendarparseCalendarDayFormat(String strDate)
parse Calendar Day Format
String pattern = "yyyy-MM-dd";
return parseCalendarFormat(strDate, pattern);
StringparseDay(Date value, String defaultValue)
Parses the day field from the given date.
if (value == null) {
    return defaultValue;
return new SimpleDateFormat("d").format(value);
DateparseDay(final String day)
Parses the given day and returns the corresponding date.
Date result = null;
if (day != null && !day.isEmpty()) {
    try {
        final SimpleDateFormat dateTimeFormat = new SimpleDateFormat(DAY);
        dateTimeFormat.setTimeZone(TimeZone.getDefault());
        result = dateTimeFormat.parse(day);
    } catch (final ParseException e) {
return result;
StringparseDay(int time)
parse Day
return yyyyMMdd.format(new java.util.Date(time * 1000L));
StringparseDay(String str, String type)
parse Day
if (type.equals("single")) {
    return "single";
if (type.equals("day")) {
    return str;
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
Date d = fmt.parse(str);
...
StringparseDayTime(long ts)
parse Day Time
return dayFormat.format(new Date(ts));