U E D R , A S I H C RSS

2학기자바스터디/운세게임

��게������ 거���고������ ���� ��게 ���� �������� �� ������ ���� ��������
���� ���� ������ � 간�������� ����

����

Date Calendar ������ ���� �� ��������

Date


~cpp 
 Date today = new Date(); // today���� ������ �� Date객 ��
 System.out.println(today); // ���� today� String���� ���� ���� ���� ����

���������� ������ SimpleDateFormat ������ � ������.


~cpp 
 SimpleDateFormat dateForm = new SimpleDateFormat("yyyy�� MM�� dd�� hh�� mm�� ss�"); // ������ 
 System.out.println(dateForm.format(today)); // today Date객�� dateForm�� �������� ��게 ����

�������� ���� ����
���� ����
y ����
M ��
d ��
h ��(1~12)
H ��(0~23)
m ��
s
S 1/1000
E ����
a ����/����

Calendar

~cpp 
 Calendar now = Calendar.getInstance(); // ���� ���고 ������������ �������� ��
 int hour = now.get(Calendar.HOUR); // ��간  기
 int min  = now.get(Calendar.MINUTE); // ��  

Calendar���� ��
�� ����
YEAR ����
MONTH ��
DATE ��
HOUR ��(1~12)
HOUROFDAY ��(0~23)
MINUTE ��
SECOND
MILLISECOND 1/1000
DAYOFWEEK ����
AMPM ����/����

�������(Random)

~cpp 
 Random r = new Random();
 int num = r.nextInt(); // Int����(-2147483648 ~ 214783647) ���� ���� ���
 int num2 = r.nextInt() % 10; // -9 ~ 9 ���� ���� 구�기
 int num3 = Math.abs(r.nextInt() % 10); // 0 ~ 9 ���� ���� 구�기. Math.abs()�� ���� 구

��

����과 � ���� ��
~cpp 
2003�� 9�� 27�� ������ ��
��:-97%
감��:43%
��:-99%
각:-96%

������ ��������� ������고
��,감��,��,�� 값 -100 ~ 100 ���� ����값���� ��(�������� ���)

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:13
Processing time 0.0133 sec