עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

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 ומשתנה DATE

Featured Replies

פורסם

אני לא מכיר את הנושא הזה

אבל אני צריך משתנה שמכיל את השעה והתאריך שבו הפעולה מתבצעת

אז עשיתי

import java.util.Date;

וכתבתי את שתי השורות הבאות

Date a = new Date();

System.out.println(a );

אני לא צריך יותר מזה אבל השעה שמתקבלת היא לא השעה שמופיע במחשב אלא השעה של המחשב פלוס שעה אחת

אני מניח שזה קשור ל TIME ZONE אבל כמו שכתבתי אני לא מכיר את הנושא ואת המתודות הרלוונטיות.

אם למשהוא יש מושג איך לסדר את זה אני אודה לו

----------עריכה -------------

טוב לא חשוב הסתדרתי וזה הקוד למי שזה מעניין אותו

import java.util.Calendar;

import java.util.TimeZone;

import java.text.SimpleDateFormat;

public class DateUtils {

public static void main(String arg[]) {

Calendar cal = Calendar.getInstance();

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

// sdf.setTimeZone(TimeZone.getDefault());

sdf.setTimeZone(TimeZone.getTimeZone("GMT+02:00"));

System.out.println("Now : " + sdf.format(cal.getTime()));

}

}

מה שלא הצלחתי להבין זה למה TimeZone.getDefault מחזיר י-ם והוא עדיין טועה בשעה

ורק כשכתבתי בפרוש GMT+2:00 זה היסתדר .

פורסם

יכול להיות שהוא טועה בגלל שעון הקיץ -- ראה כאן

פורסם
  • מחבר

ההיתי צריך לנחש

תודה על התגובה

אני אבדוק את זה

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

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.