Skip to content

Commit 209366e

Browse files
committed
all
1 parent 37c70db commit 209366e

File tree

17 files changed

+222
-0
lines changed

17 files changed

+222
-0
lines changed

Evaluvation-2 (mar 21)/.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Evaluvation-2 (mar 21)/.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Evaluvation-2 (mar 21)/.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Evaluvation-2 (mar 21)/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>
2.17 KB
Binary file not shown.
1.38 KB
Binary file not shown.
1.62 KB
Binary file not shown.
1.87 KB
Binary file not shown.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.masai.question1;
2+
3+
import java.time.LocalDate;
4+
import java.time.Period;
5+
import java.time.format.DateTimeFormatter;
6+
import java.util.Scanner;
7+
import java.util.zip.DataFormatException;
8+
9+
public class Main {
10+
11+
public static void main(String[] args) {
12+
13+
14+
15+
Scanner sc = new Scanner(System.in);
16+
System.out.println("Enter your DOB in dd/MM/yyyy");
17+
String udob = sc.next();
18+
19+
try {
20+
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd/MM/yyyy");
21+
22+
LocalDate cur = LocalDate.now();
23+
24+
LocalDate fDate = LocalDate.parse(udob, dtf);
25+
26+
Period p = Period.between(fDate, cur);
27+
if (p.getYears() < 0) {
28+
System.out.println("Date of birth should not be in future");
29+
} else {
30+
System.out.println("You are " + p.getYears() + " old now");
31+
}
32+
} catch (Exception se) {
33+
System.out.println("please pass the date in the proper format");
34+
}
35+
36+
37+
}
38+
}

0 commit comments

Comments
 (0)