الانتقال إلى المحتوى
View in the app

A better way to browse. Learn more.

مجموعة مستخدمي أوراكل العربية

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

طلب مساعده: java class اريد حساب العمر بالتاريخ والاشهر سنين ساعات ايام اسابيع

Featured Replies

بتاريخ:

اريد برنامج حساب العمر سنين ايام شهور ساعات
ان وجد
او طريقة عمله الرجا المساعده java class

  • بعد 2 أسابيع...
بتاريخ:

this java class will help ya
to get the age by years, Months & days but without hours


import java.util.*;
import java.io.*;

public class AgeCalculation{
 public static void main(String[] args) throws IOException{
   int day = 1, month = 0, year = 1, ageYears, ageMonths, ageDays;
   BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
   Calendar cd = Calendar.getInstance();
   try{
     System.out.print("Enter year of your date of birth : ");
     year = Integer.parseInt(in.readLine());
     if(year > cd.get(Calendar.YEAR)){
       System.out.print("Invalid date of birth.");
       System.exit(0);
     }
     System.out.print("Enter month of your date of birth : ");
     month = Integer.parseInt(in.readLine());
     if(month < 1 || month > 12){
       System.out.print("Please enter monthe between 1 to 12.");
       System.exit(0);
     }
     else{
       month--;
       if(year == cd.get(Calendar.YEAR)){
         if(month > cd.get(Calendar.MONTH)){
           System.out.print("Invalid month!");
           System.exit(0);
         }
       }
     }
     System.out.print("Enter day of your date of birth : ");
     day = Integer.parseInt(in.readLine());
     if(month == 0 || month == 2 || month == 4 || month == 6 || month == 7 || 
month == 9 || month == 11){
       if(day > 31 || day < 1){
         System.out.print("Please enter day between 1 to 31.");
         System.exit(0);
       }
     }
     else if(month == 3 || month == 5 || month == 8 || month == 10){
       if(day > 30 || day < 1){
         System.out.print("Please enter day between 1 to 30.");
         System.exit(0);
       }
     }
     else{
       if(new GregorianCalendar().isLeapYear(year)){
         if(day < 1 || day > 29){
           System.out.print("Please enter day between 1 to 29.");
           System.exit(0);
         }
       }
       else if(day < 1 || day > 28){
         System.out.print("Please enter day between 1 to 28.");
         System.exit(0);
       }
     }
     if(year == cd.get(Calendar.YEAR)){
       if(month == cd.get(Calendar.MONTH)){
         if(day > cd.get(Calendar.DAY_OF_MONTH)){
           System.out.print("Invalid date!");
           System.exit(0);
         }
       }
     }
   }
   catch(NumberFormatException ne){
     System.out.print(ne.getMessage() + " is not a legal entry!");
     System.out.print("Please enter number.");
     System.exit(0);
   }
   Calendar bd = new GregorianCalendar(year, month, day);
   ageYears = cd.get(Calendar.YEAR) - bd.get(Calendar.YEAR);
   if(cd.before(new GregorianCalendar(cd.get(Calendar.YEAR), month, day))){
     ageYears--;
     ageMonths = (12 - (bd.get(Calendar.MONTH) + 1)) + (bd.get(Calendar.MONTH));
     if(day > cd.get(Calendar.DAY_OF_MONTH)){
       ageDays = day - cd.get(Calendar.DAY_OF_MONTH);
     }
     else if(day < cd.get(Calendar.DAY_OF_MONTH)){
       ageDays = cd.get(Calendar.DAY_OF_MONTH) - day;
     }
     else{
       ageDays = 0;
     }
   }
   else if(cd.after(new GregorianCalendar(cd.get(Calendar.YEAR), month, day))){
     ageMonths = (cd.get(Calendar.MONTH) - (bd.get(Calendar.MONTH)));
     if(day > cd.get(Calendar.DAY_OF_MONTH))
       ageDays = day - cd.get(Calendar.DAY_OF_MONTH) - day;
     else if(day < cd.get(Calendar.DAY_OF_MONTH)){
       ageDays = cd.get(Calendar.DAY_OF_MONTH) - day;
     }
     else
       ageDays = 0;
   }
   else{
     ageYears = cd.get(Calendar.YEAR) - bd.get(Calendar.YEAR);
     ageMonths = 0;
     ageDays = 0;
   }
   System.out.print("Age of the person : " + ageYears + " year, " + ageMonths + 
" months and " + ageDays + " days.");
 }
} 

بتاريخ:
  • كاتب الموضوع

الف الف شكر ماقصرت الله يعطيك العافيه

  • بعد 2 سنة...
بتاريخ:

شكرا للمشاركة القيمة نستفيد من هذا العمل

بتاريخ:

يمكنك استخدام الدالة getTime الموجودة في java.util.Date بحيث تقوم بإرجاع الزمن بالملي ثانية وبالتالي يمكنك القسمة على 1000 لتصبح بالثانية ثم القسمة على 60 لتصبح بالدقيقة ثم القسمة على 60 لتصبح بالساعة ثم القسمة على 24 لتصبح باليوم وهكذا

انضم إلى المناقشة

يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.

زائر
أضف رد على هذا الموضوع...

برجاء الإنتباه

بإستخدامك للموقع فأنت تتعهد بالموافقة على هذه البنود: سياسة الخصوصية

Account

Navigation

البحث

إعداد إشعارات المتصفح الفورية

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.