Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Java OOP
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; class Rextester { String name = "Andrey Sotnikov"; String dob = "02/07/1984"; void print(String param) { System.out.println(param); } 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{ Rextester o = new Rextester(); o.print("Name: " + o.name + " Age: " + o.age(o.dob)); } }
[
+
]
Show input
Compilation time: 0.72 sec, absolute running time: 0.24 sec, cpu time: 0.14 sec, memory peak: 34 Mb, absolute service time: 0.97 sec
edit mode
|
history
|
discussion
Name: Andrey Sotnikov Age: 31