LoginSignup
2
2

More than 3 years have passed since last update.

String型をTimestamp型に変換する

Posted at

String型からTimestamp型に変換する

            //String型からTimestamp型へ変換をする     
            //formから値を受け取り結合する
            String delivery = form.getDeliveryDate() + " " + form.getDeliveryTime();
            //format変換する為の記述
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh");
            java.util.Date parsedDate = null;
            try {
                parsedDate = dateFormat.parse(delivery);
            } catch (ParseException e) {
                e.printStackTrace();
            }
            Timestamp timestamp = new java.sql.Timestamp(parsedDate.getTime());

備忘録として残します。
他に何か良いやり方があればご教授お願いします!

2
2
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2