Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java get difference days without weekends

DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    Date date1 = df.parse("10/08/2013");
    Date date2 = df.parse("21/08/2013");
    Calendar cal1 = Calendar.getInstance();
    Calendar cal2 = Calendar.getInstance();
    cal1.setTime(date1);
    cal2.setTime(date2);

    int numberOfDays = 0;
    while (cal1.before(cal2)) {
        if ((Calendar.SATURDAY != cal1.get(Calendar.DAY_OF_WEEK))
           &&(Calendar.SUNDAY != cal1.get(Calendar.DAY_OF_WEEK))) {
            numberOfDays++;
        }
        cal1.add(Calendar.DATE,1);
    }
    System.out.println(numberOfDays);
Comment

PREVIOUS NEXT
Code Example
Java :: How to Access Elements of an Array in Java? 
Java :: expandablelistview android 
Java :: ArrayList go to value jav 
Java :: paysimple 
Java :: save ArrayList into Room Database android studio 
Java :: Java/Perl - "sprintf function in java" or "string format" 
Java :: Execute method on load 
Java :: spigot give item 
Java :: tests offline cypress 
Java :: random number in java between 10 and 20 
Java :: how to install java jdk 8 on ubuntu 20.04 for spark 
Java :: string stack in java 
Java :: steps to accomplish jdbc connection in java 
Java :: min_value java 
Java :: bloomreach get node via id 
Java :: ternärer operator java 
Java :: cannot write data document seems to have been closed already in java 
Java :: ferrari class in java 
Java :: make a string bean spring xml 
Java :: They say that they have to create an instance to their application. What does it mean? 
Java :: kubernetes java client create namespace 
Java :: com.google.firebase.database.DatabaseException: Serializing Arrays is not supported, please use Lists instead 
Java :: what is abstract class 
Java :: what is inheritance in java 
Java :: autowired in spring 
Java :: || in java 
Java :: how to get stack trace of a function in java 
Java :: java file path linux 
Java :: taglib in jsp 
Java :: why is java so verbose 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =