Skip to content

Commit 1cc4fb2

Browse files
authored
Create TarihFormati.java
1 parent 79ad325 commit 1cc4fb2

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

TarihFormati.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.company;
2+
3+
import java.util.Scanner;
4+
5+
public class TarihFormati {
6+
public static void main(String args[]){
7+
Scanner scanner = new Scanner(System.in);
8+
System.out.println("Örnek Format: 26/01/2000");
9+
System.out.print("Tarih Giriniz: ");
10+
String tarih = scanner.nextLine();
11+
int cizgisayi = 0;
12+
for(int i = 0; i < tarih.length(); i++){
13+
if(tarih.charAt(i) == '/'){
14+
cizgisayi++;
15+
}
16+
}
17+
if(cizgisayi == 2){
18+
String[] tarihi = tarih.split("/");
19+
System.out.println(tarihi[2]+"/"+tarihi[1]+"/"+tarihi[0]);
20+
}else{
21+
System.out.println("Tarih Formatı Hatalı");
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)