Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Calculate 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

Calculate 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 :: final method java 
Java :: Java If ... Else 
Java :: palindrome in java 
Java :: java @override 
Java :: how to draw a circle in java swing 
Java :: how to create a boolean list in java 
Java :: java file path linux 
Java :: string program to calculate number of characters in a string java 
Java :: springboot avoid generated security password: 
Java :: code to get date and time in android 
Java :: connection data base java code 
Java :: print outputstream to console java 
Java :: $950 at 6% per annum for three years. 
Java :: java dato numero big starkoverflow 
Java :: java streams example 
Sql :: mysql workbench turn off safe mode 
Sql :: TSQL GET ALL COLUMNS IN TABLE 
Sql :: oracle all tables in schema 
Sql :: drop stored procedure mysql 
Sql :: oracle get current schema 
Sql :: see all databases mysql 
Sql :: sql server beginning of month 
Sql :: mac xampp mysql not starting 
Sql :: pdo mysql insert 
Sql :: ubuntu stop mysql 
Sql :: rename table sql 
Sql :: mssql current date 
Sql :: create table sql server 
Sql :: drop foreign key 
Sql :: Check Table Exists 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =