BAEL-994 - TemporalAdjuster in Java (#2232)
* Evaluation article: Different Types of Bean Injection in Spring * added tests & changed configuration to Java-based config * removed xml config files * rename unit tests * BAEL-972 - Apache Commons Text * remove code from evaluation article * remove code from evaluation article * BAEL-972 - Apache Commons Text - added another example * BAEL-972 - Apache Commons Text - just indentation * BAEL-994 - TemporalAdjuster in Java * BAEL-994 - TemporalAdjuster in Java * BAEL-994 - TemporalAdjuster in Java * BAEL-994 - TemporalAdjuster in Java * BAEL-994 - TemporalAdjuster in Java - fix problems
This commit is contained in:
committed by
Grzegorz Piwowarek
parent
f876c6d02e
commit
13eec7e57c
@@ -1,31 +0,0 @@
|
||||
package com.baeldung.temporaladjuster;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
public class TemporalAdjusterUtil {
|
||||
|
||||
public static Calendar nextDayOfWeek(int dayOfWeek) {
|
||||
Calendar date = Calendar.getInstance();
|
||||
int difference = dayOfWeek - date.get(Calendar.DAY_OF_WEEK);
|
||||
if (!(difference > 0)) {
|
||||
difference += 7;
|
||||
}
|
||||
date.add(Calendar.DAY_OF_MONTH, difference);
|
||||
return date;
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public static String getNextWorkingDay() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
format.setCalendar(calendar);
|
||||
if (calendar.DAY_OF_WEEK == Calendar.FRIDAY)
|
||||
calendar.add(Calendar.DATE, 3);
|
||||
if (calendar.DAY_OF_WEEK == Calendar.SATURDAY)
|
||||
calendar.add(Calendar.DATE, 2);
|
||||
else
|
||||
calendar.add(Calendar.DATE, 1);
|
||||
return format.format(calendar.getTime());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user