#author("2023-12-19T12:03:08+09:00","default:irrp","irrp") →[[Java関連]] →Javaのリフレクション →Java文法系Tips →Eclipse関連 →JavaのWebアプリ開発 #contents *サブトピック [#ta8966cb] -Java関連Tipsサンプル集 *Tips集Webサイト [#t58aeb52] -[[裏Javaメモ>http://www.ne.jp/asahi/hishidama/home/tech/java/strange.html]] --Javaの微妙なネタ -[[Java(SE) API逆引き辞典>http://always-pg.com/java/j2se_rd/]] -[[Javaのとても小さい小技メモ>http://kamakura.cool.ne.jp/oppama/jaco/index.html]] -[[Java 逆引きリファレンス>http://www.stackasterisk.jp/tech/javaClassref/index.jsp]] -[[Java Tips index@IT>http://www.atmarkit.co.jp/fjava/javatips/index.html]] -[[Java Tips集>http://www.masatom.in/pukiwiki/Java/TIPS%BD%B8/]] *一般 [#q73809c7] -[[Java 21のSequenced Collectionsのreversedの実装について | GMOアドパートナーズ TECH BLOG byGMO>https://techblog.gmo-ap.jp/2023/12/15/java-21-sequenced-collections/]] 2023.12 -[[Java 11で導入されたHTTPクライアント(JEP 321 HTTP Client)を試す - CLOVER🍀>https://kazuhira-r.hatenablog.com/entry/2023/09/03/204511]] 2023.9 -[[Java VMのヒープサイズをパーセンテージで指定する(-XX:InitialRAMPercentage、-XX:MaxRAMPercentage) - CLOVER🍀>https://kazuhira-r.hatenablog.com/entry/2023/07/09/212521]] 2023.7 -[[【ネタ】コメントだけしか書いていないのに「Hello, world!」と表示されるJavaプログラム - Qiita>https://qiita.com/cha84rakanal/items/06477529d48c52f26e2d]] 2023.5 -[[POIを使わずJava標準ライブラリでExcelファイルを生成する - きしだのHatena>https://nowokay.hatenablog.com/entry/2023/03/04/052703]] 2023.3 * 並行処理 [#q4b64f74] -[[Virtual Threadsを使ってHTTPサーバー/クライアントを書いて、スレッドまわりの動きを確認してみる(スレッドダンプの取得付き) - CLOVER🍀>https://kazuhira-r.hatenablog.com/entry/2023/12/14/001741]] 2023.12 -[[Java 21で正式版になったJEP 444(Virtual Threads)に関するAPIを試す - CLOVER🍀>https://kazuhira-r.hatenablog.com/entry/2023/12/10/182732]] 2023.12 -[[Java 21仮想スレッドではsynchronizedの代わりにReentrantLockを使用する #Java - Qiita>https://qiita.com/cypher256/items/e7be58ebad6f745a2e21]] 2023.11 -[[Javaの並列/並行処理の基本 - Speaker Deck>https://speakerdeck.com/skrb/bing-xing-chu-li-noji-ben]] 2023.6 -[[Javaで最強 コンカレントプログラミング/concurrent-programming-in-java - Speaker Deck>https://speakerdeck.com/oracle4engineer/concurrent-programming-in-java]] 2023.4 -[[Java並行・並列・非同期処理チートシート - Qiita>https://qiita.com/yohhoy/items/bc119324d2b69570597b#%E4%B8%A6%E8%A1%8C%E3%82%B3%E3%83%B3%E3%83%86%E3%83%8A]] 2014 -[[ArrayListをスレッドセーフ化するには? | SYMMETRICソフトウェア開発ブログ>https://www.symmetric.co.jp/blog/archives/29]] 2020 --普通にSynchronizedを使う手とSynchronizedCollection<E> を使う手がある -[[Concurrency Utilities for Java EE を実装する API タスクの例 - IBM Documentation>https://www.ibm.com/docs/ja/was-liberty/nd?topic=SSAW57_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/rwlp_migrate_to_eeconcurrency.html]] 2022.3 * JavaのSerializableを実際にアプリケーションを動かしながら理解する [#qfbd3fb6] -[[JavaのSerializableを実際にアプリケーションを動かしながら理解する>https://qiita.com/taumax/items/1559439efe0607595465]] 2020.7 *util.Objects [#g06e922b] -[[クラス java.util.Objectsのおさらいメモ>https://qiita.com/rubytomato@github/items/ba38877ed5a00dd24f16]] 2020.5 *日付/時刻処理いろいろ [#wa075aaa] -[[Java の DateTimeFormatter の指定方法について>https://zenn.dev/cloud_ace/articles/b398d173e1877d]] 2023.11 -[[DateTimeFormatでは、JSONで受け取った日付をうまく取得できない場合があるという話 - エキサイト TechBlog.>https://tech.excite.co.jp/entry/2022/05/10/170359]] 2022.5 -[[Javaの日付の差分処理はDurationを使おう!!>https://qiita.com/tora_kouno/items/d230f904a2b768ccb319]] 2021.7 -[[Javaバージョン別の改元(新元号)対応まとめ>https://qiita.com/yamadamn/items/56e7370bae2ceaec55d5]] 2019.1 -Timestamp型からDateを経由してCalendarを作る java.util.Date = new java.util.Date(ts.getTime()); Calendar now = Calendar.getInstance(); now.setTime(date); -ISO8601形式の日付をDate型に変換して返す [#r37f066f] public static Date Iso8601toDate(String isoDate) throws java.text.ParseException{ try { Calendar cal =DatatypeConverter.parseDateTime(isoDate); return cal.getTime(); } catch (ParseException e) { e.printStackTrace(); return null; } } -カレント月(YYYYMM)取得 java.util.Date dtNow = new java.util.Date(); SimpleDateFormat formatter = new SimpleDateFormat ("yyyyMM"); String ymNow = formatter.format(dtNow); -1月進めて月を取得 Date dt = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(dt); calendar.add(Calendar.MONTH, 1); dt = calendar.getTime(); SimpleDateFormat formatter = new SimpleDateFormat ("yyyyMM"); String ymNow = formatter.format(dt); *Runtime#addShutdownHookで JVM 終了時に処理を実行する [#g1cf1f8e] -http://www.smallstyle.com/20070215.html *Velocity [#nca80fcf] -[[汎用テンプレートエンジンVelocity>http://www.stackasterisk.jp/tech/java/velocity01_01.jsp]] --http://velocity.apache.org/ *マルチスレッド [#z0afd4c1] -[[Java: Threadおさらい - Qiita>https://qiita.com/e99h2121/items/8eb3e031529083901485]] 2021.11 -[[マルチスレッドプログラミングの入門>http://programming-10000.hatenadiary.jp/entry/20140530/1401450268]] 2014.5.30 -チュートリアル --http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html *強制ガベージコレクション [#m2465ffe] -System.gc() もしくは Runtime.getRuntime().gc() *BigDecimalの丸め方 [#p8673458] -http://always-pg.com/java/j2se_rd/number/setscale.html *ファイル一覧取得 [#fa0747de] -http://sattontanabe.blog86.fc2.com/blog-entry-56.html *Java のスタンドアロンプログラムで終了コードを設定するには [#td9a655b] System.exit(-1); *PDFを生成する [#tc59c185] -http://www.atmarkit.co.jp/fjava/javatips/121jspservlet41.html *XMLに対応したProperties [#z37787f0] -http://www.javainthebox.net/laboratory/J2SE1.5/TinyTips/Properties/Properties.html *シリアルバージョンUIDの生成 [#if425795] -シリアライズを実装するクラスにはUIDをつける必要がある -解説:http://www.javaroad.jp/faq/faq_os_eclipse1.htm -Eclipseではワーニングの出た位置にカーソルを合わせてCtrl+1を押すと生成できる *実行時の対応ソース行取得 [#o969aba2] int line = (new Throwable().getStackTrace()[0]).getLineNumber(); *Javaオブジェクトのハッシュコードのルール [#w3ff9fa1] -The hashCode( ) method is supposed to return an int that should uniquely identify different objects. -A properly written hashCode( ) method will follow these rules: --It is repeatable: hashCode(x) must return the same int when called repeatedly, unless set methods have been called. --It is consistent with equality: if x.equals(y), then x.hashCode( ) must == y.hashCode( ). --If !x.equals(y), it is not required that x.hashCode( ) != y.hashCode( ), but doing so may improve performance of hash tables; i.e., hashes may call hashCode( ) before equals( ). -The default hashCode( ) on Sun's JDK returns a machine address, which conforms to Rule 1. Conformance to Rules 2 and 3 depends, in part, upon your equals( ) method. Here is a program that prints the hashcodes of a small handful of objects: *コンパイラの警告抑制 [#u5033083] -↓のアノテーションをメソッドにつけるとキャストのときに出る警告を抑制できる @SuppressWarnings("unchecked") あまり推奨はできないが… *バイト配列から文字列への変換 [#g90835e2] -[[Javaで整数型やbyte配列と16進表記の文字列との間の変換を行なう - エキサイト TechBlog.>https://tech.excite.co.jp/entry/2023/12/19/063000]] 2023.12 result = new String(bytes, offset, length, charsetName); -charsetName は "shift-jis"とか *Javaのソース解析/AST(Abstract Syntax Tree) [#o15fd42f] -[[ASTを活用してコードの自動修正に挑戦してみよう - Cybozu Inside Out | サイボウズエンジニアのブログ>https://blog.cybozu.io/entry/2018/09/07/080000]] 2018 -[[JavaParser 使い方メモ>https://qiita.com/opengl-8080/items/50ddee7d635c7baee0ab]] 2017 -[[JDTでJavaのソースコード解析を行う>https://qiita.com/esplo/items/fa93ab6136e7697ed1d9]] 2015 -[[Eclipse JDT AST>http://www.ne.jp/asahi/hishidama/home/tech/eclipse/plugin/develop/jdt/ast.html]] * その他 [#ha61b806] -[[Java New String Methods - From Java 8 To Java 17>https://javaconceptoftheday.com/java-new-string-methods-with-examples/]] 2022.7