Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Java Functional Programming
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; class Rextester { static String name = "Andrey Sotnikov"; static String dob = "02/07/1984"; static void print(String param) { System.out.println(param); } static long age(String param_dob) throws ParseException { SimpleDateFormat f = new SimpleDateFormat("MM/dd/yyyy"); Date date =f.parse(param_dob); long dob_ms = date.getTime(); long now_ms = System.currentTimeMillis(); return (now_ms - dob_ms) / 31_556_952_000L; } public static void main(String[] args) throws ParseException{ print("Name: " + name + ". Age: " + age(dob)); } }
run
|
edit
|
history
|
help
0
Bound Types
++a vs a++ and calculations around different variables
Convert string array to lowercase.
contoh 43
qwe
Words with same letters
Compare Version Numbers
Huffman Encoding Tree v2
Jh
Random and count of even numbers (ver. 2)