忍者ブログ
[1]  [2
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

■Java.util.Date 日時を表現するクラス
1970年1月1日 00:00:00 GMT(エポック)からのミリ秒数を表すlong値
 ⇒日付と時間フィールドの間の変換には、Calendarクラス
 ⇒日付文字列のフォーマットと構文解析には、DateFormatクラス

・現在時刻を取得
 Date current = new Date();
  curent.toString(); →Tue Mar 20 13:57:12 JST 2007

 Date after = new Date(System.currentTimeMillis()); //long型の引数

■Java.util.Calendar
・現在時刻を取得(DateFormatクラスと一緒に使用する)
 Calendar current = Calendar.getInstance();
 current.toString(); →java.util.GregorianCalendar[time=117436682144…

■型変換
・DateからCalendarに変換
 Calendar current = Calendar.getInstance();
 current.setTime(new Date());
 
・CalendarからDateに変換
 Date current = Calendar.getInstance().getTime();

・Date→「エポックからのミリ秒」変換
 long current = new Date().getTime(); →1174368381739

・「エポックからのミリ秒」→Calendar変換
 Calendar current = Calendar.getInstance();
 current.setTimeInMillis(System.currentTimeMillis()); //long型の引数

・Calendar→「エポックからのミリ秒」変換
 long current = Calendar.getInstance().getTimeInMillis();

■java.util.SimpleDateFormat 日時型を文字列に変換
 SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm;ss");
 sdf.format(new Date());
 sdf.format(Calendar.getInstance().getTime());

■java.sql.Date(java.util.Dateとの違い)
 //
 GregorianCalendar gc = new GregorianCalendar(2005,0,1);
 Date date = gc.getTime();
 
 DateFormat df = DateFormat.getInstance();
 String strDate1 = df.format(date);
 System.out.println(strDate1); //→05/01/01 0:00
 
 Date date2 = new Date();
 gc.setTime(date2);
 gc.add(Calendar.YEAR, 3);
 System.out.println(gc.get(Calendar.YEAR) + "/" + (gc.get(Calendar.MONTH) + 1)
  + "/" + gc.get(Calendar.DATE)); //→2011/11/4
 
 //java.sql.Dateはパラメータにlong値を必要とする
 java.sql.Date date3 = new java.sql.Date(gc.getTimeInMillis());
 System.out.println(date3); //→2011-11-04
 GregorianCalendar gc2 = new GregorianCalendar();
 
 gc2.setTimeInMillis(date3.getTime());
 gc2.add(Calendar.YEAR, -2);
 System.out.println(gc2.get(Calendar.YEAR) + "/" + (gc2.get(Calendar.MONTH) + 1)
  + "/" + gc2.get(Calendar.DATE)); //→2009/11/4

PR
■ファイルの入出力
FileInputStream(FileOutputStream)
 //生のバイト(イメージデータなど)のストリームを読み書き ⇔ 文字ストリーム FileReader
FileReader(FileWriter)
 //文字単位で入出力を行う。
InputStreamReader(OutputStreamWriter)
 //バイトストリームから文字ストリームへの橋渡しをする。指定されたcharsetを使用して文字に変換する。
 変換効率を最高にするにはBufferedReaderの内部にInputStreamReaderをラップする事を考慮する必要がある。
  BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
BufferedReader(BufferedWriter)
 //文字、配列、行をバッファリングすることにより、文字型入力ストリームからテキストを効率よく読み込める。
File(Java.io.File)
 //ファイルおよびディレクトリのパス名の抽象表現
引き続き↓を参考にお勉強
http://www.fumikichan.net/prog/Servlet/kd030101.jsp

構成はこんな感じ。
[P]UserCheck
  + JREシステム・ライブラリー
  + TOMCAT_HOME/common/../servlet.jar
  + TOMCAT_HOME/common/../jasper-runtime
  + struts.jar
  - [D]WEB-INF/src
    - デフォルトパッケージ
      + LoginAction.java
      + LoginForm.java
      + UserCheckActionMapping.java
    - ApplicationResources.properties
  + [D] work
  - [D] WEB-INF
    - [D]classes
      + [D]org
      - ApplicationResources.properties
      - LoginAction.class
      - LoginForm.class
      - UserCheckActionMapping.class
    - [D] lib
      - xxxx.jar
    - [D] src
      - ApplicationResources.properties
      - LoginAction.java
      - LoginForm.java
      - UserCheckActionMapping.java
    - struts-bean.tld
    - struts-config.xml
    - struts-html.tld
    - web.xml
  - index.jsp
  - login.jsp

MySQLの設定とかごちゃごちゃ。

■起動と停止
 C:\> net start MySQL5
 C:\> net stop MySQL5

■操作
 mysql -u root
 mysql -u root -pxxx
※パスワード付の場合は-pの後、空白を空けずに入力する。

・作成済みのDBを見る
 show databases;

・DBの作成
 create database xxxxx;

・DBへの接続
 connect xxxx;

・テーブル作成(エラー1064がのきなみ)
create table USERM (
ID char(5) NOT NULL primary key,
USERNAME char(10) NOT NULL,
PASS char(10) NOT NULL
)

JDBCドライバインストール web.xmlの修正
===============================
セッション固定攻撃の脆弱性について対応策

 

カレンダー
04 2025/05 06
S M T W T F S
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
フリーエリア
最新コメント
最新トラックバック
プロフィール
HN:
学kun
性別:
男性
バーコード
ブログ内検索
P R
Copyright © 毎日勉強頑張ってます! All Rights Reserved.
Powered by NinjaBlog
Graphics by 写真素材Kun * Material by Gingham * Template by Kaie
忍者ブログ [PR]