Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Calculate weeks from date using java

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 :: java program to print vowels in a string 
Java :: mp3 player java 
Java :: find power of number in method java 
Java :: how to set default color in android studio 
Java :: java deserialize json object 
Java :: finding min and max from given number in java 
Java :: java float precision 
Java :: arraylist remove value in java 
Java :: loop through array in java 
Java :: java swing date picker 
Java :: for var i = 0 
Java :: java string copy characters 
Java :: rest api client url not connecting to the database in spring boot 
Java :: grepper mcm java 
Java :: Fab to CircularRevealFrameLayout example 
Sql :: reset ids in mysql 
Sql :: oracle drop job 
Sql :: oracle get table schema 
Sql :: sql add column after another 
Sql :: grant revoke privileges to mysql username 
Sql :: mysql show databases 
Sql :: how to restart mysql in linux 
Sql :: check current sequence value postgres 
Sql :: postgresql change column type 
Sql :: how to drop databaselink in oracle 
Sql :: how to set an already made tables auto increment in mysql 
Sql :: how to export db from mysql 
Sql :: oracle user last connected 
Sql :: postgres DROP and create contraint 
Sql :: t-sql test if table exists 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =