Here you can find the source of getDateDelta(int delta, String dateFormat)
Parameter | Description |
---|---|
delta | Value for `days` delta. |
dateFormat | a parameter |
public static String getDateDelta(int delta, String dateFormat)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; public class Main { public static final String DATE_FORMAT = "yyyy-MM-dd G HH:mm:ss z"; /**// w w w. j a va2 s.c o m * Returns date delta from current time with `dateFormat` * @param delta * Value for `days` delta. * @param dateFormat * @return */ public static String getDateDelta(int delta, String dateFormat) { Calendar current = Calendar.getInstance(); current.add(Calendar.DATE, delta); return formatDate(current.getTime(), dateFormat); } /** * Format date with default `DATE_FORMAT` and default locale `Locale.KOREA` * @param date * @return */ public static String formatDate(Date date) { return formatDate(date, DATE_FORMAT); } /** * Format date with `dateFormat` given and default locale `Locale.KOREA` * @param date * @param dateFormat * @return */ public static String formatDate(Date date, String dateFormat) { return formatDate(date, dateFormat, Locale.ENGLISH); } /** * Format date * @param date * `Date` formatted to * @param dateFormat * Date format like 'yyyy-MM-dd' * @param locale * Locale for date format. * @return * Formatted date string */ public static String formatDate(Date date, String dateFormat, Locale locale) { SimpleDateFormat format = new SimpleDateFormat(dateFormat, locale); return format.format(date); } }