If Java application is started with -XX:+PrintGCApplicationStoppedTime, gc log will contain the application stopped time (STW) caused by different reasons (e.g. GC is just one common reason). This one-liner parses the gc log and only prints out the stopped time caused by GC.
Source: https://github.com/giltene/jHiccup
12345
// gc log with +PrintGCTimeStamps
awk -F": "'/\[GC/ {t = $1; l = 1; while ((l == 1) && index($0, "Total time") == 0) { l = getline; } if (l == 1) {print t*1000.0, $3*1000.0;}}' gc.log
// gc log with +PrintGCTimeStamps and +PrintGCDateStamps
awk -F": "'/\[GC/ {t = $2; l = 1; while ((l == 1) && index($0, "Total time") == 0) { l = getline; } if (l == 1) {print t*1000.0, $4*1000.0;}}' gc.log