Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Get the number of weeks between two dates

SimpleDateFormat myFormat = new SimpleDateFormat("dd MM yyyy");
String classStartData = "31 01 2021";
String classEndData = "08 03 2021";

Date dateClassStart = myFormat.parse(classStartData);
Date dateClassEnd = myFormat.parse(classEndData);

long differenceWeek = dateClassEnd.getTime() - dateClassStart.getTime();
int programLength = (int)(TimeUnit.DAYS.convert(differenceWeek, TimeUnit.MILLISECONDS)/7);
System.out.println("Class length in weeks: " +programLength);
Comment

PREVIOUS NEXT
Code Example
Java :: how to call a void method from another class in java 
Java :: how to get stack trace of a function in java 
Java :: casting in java 
Java :: synchronized block in java 
Java :: Java if (if-then) Statement 
Java :: java compare char 
Java :: xml button color not changing 
Java :: how to add a number to the ascii value of a char in java 
Java :: number of matches regex java 
Java :: maven set repository location command line 
Java :: x = x + y; in java 
Java :: Android java toArray to String array 
Java :: save text in edditext java 
Java :: como limpar a tela do consola no java 
Java :: android studio fecth audio from app directory 
Sql :: sql server search column name in all tables 
Sql :: postgresql find biggest table 
Sql :: oracle find all tables with column name 
Sql :: start postgresql 
Sql :: list all triggers in sql server 
Sql :: create database if not exists 
Sql :: string to int mysql 
Sql :: mysql change database charset and collation 
Sql :: get current date in pyspark sql 
Sql :: sql query to make a existing column auto increment 
Sql :: wordpress database query change url 
Sql :: delete first row in sql 
Sql :: sql last 7 days 
Sql :: stop mysql ubuntu 
Sql :: how to add a index to live table sql 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =