انتقل إلى المحتوى
أمين أبوزيد
BEG-033

التاريخ والوقت

  • 5 درس
  • 54 دقيقة قراءة
  • 2 ساعة تدريب (تقدير)
في هذه الصفحة 8 موضوعات

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

نظرة عامة

الموضوعات

  • LocalDate
  • LocalDateTime
  • Instant
  • Duration
  • ZonedDateTime
  • المناطق الزمنية

تعلّم أولًا

54 دقيقة قراءة · 2 ساعة تدريب (تقدير)

مخرجات التعلم

  1. Choose between LocalDate, LocalDateTime, Instant, and ZonedDateTime for a requirement.
  2. Do date arithmetic with Duration and Period.
  3. Parse and format dates with DateTimeFormatter.
  4. Explain why timestamps should be stored in UTC and converted for display.

الدروس

  1. 01لماذا الوقت صعب11 د قراءة
  2. 02التواريخ والأوقات المحلية11 د قراءة
  3. 03اللحظات (Instants) والمناطق الزمنية10 د قراءة
  4. 04المدد والفترات والتنسيق11 د قراءة
  5. 05عرض عملي: اجتماع عبر مناطق زمنية وتغيير التوقيت الصيفي11 د قراءة

المختبر والتمارين

Lab

BEG-033-LAB1 · Meeting planner

Outcomes: 1–4 · Time: ~1.5 h Schedule a meeting in one time zone and show it in three others. Compute days until a deadline. Store the meeting as an Instant and explain in a comment why. Acceptance: correct across a daylight-saving change.

Exercises (assessment: three exercises)

IDOutcomeTask
BEG-033-EX011Choose the type for each: a birthday; a log timestamp; a flight departure with its city's zone; "9 am every day" alarm.
BEG-033-EX022, 3Compute the days between today and 31 December, and the hours between 08:30 and 17:45. Then print a date as 15 Mar 2026.
BEG-033-EX034Write two sentences on why a database should store UTC timestamps and convert at display time.
أظهر الحلول
  • EX01 LocalDate; Instant; ZonedDateTime; LocalTime.
  • EX02 ChronoUnit.DAYS.between(LocalDate.now(), LocalDate.of(year, 12, 31)); Duration.between(LocalTime.of(8,30), LocalTime.of(17,45)).toHours() gives 9 (hours part; toMinutes() gives 555); format with ofPattern("dd MMM yyyy").
  • EX03 UTC has no daylight saving and is one fixed reference, so sorting and comparing are correct and data from many zones agrees. Each user then sees their own local time, converted when displayed.
  • Outcome 2 is also covered by the lab and quiz Q05–Q06.

الاختبار

Outcomes: O1 choosing types · O2 Duration and Period · O3 formatting and parsing · O4 UTC storage.

اختبار ذاتي لك: لا توجد درجات، ولا يُحفظ أو يُرسل أي شيء. اختر إجابة ثم تحقق منها، ويمكنك المحاولة مرة أخرى كما تشاء.

  1. 1Best type for a birthday:O1
  2. 2Best type for a database "created at" timestamp:O1
  3. 3Which type is NOT a specific moment on the global timeline?O1
  4. 4An event in several time zones should use:O1
  5. 5For hours and minutes use:O2
  6. 6For years, months, days use:O2
  7. 7In DateTimeFormatter patterns, MM means:O3
  8. 8LocalDate.plusDays(5):O3
  9. 9Why store timestamps in UTC?O4
  10. 10Which should you avoid in new code?O1

الجزء العملي

Three exercises BEG-033-EX01 to EX03 plus the lab. Pass: all three exercises correct and the lab correct across a daylight-saving change.

أخطاء شائعة

LocalDateTime for events in multiple time zones; legacy Date.

التقييم

3 exercises.

الصلة بالمسار الوظيفي

Timestamps in databases (JNR-028) and distributed clocks (MID-023).

اكتب للبحث في المستويات والمراحل والوحدات والدروس.