有没有办法添加需求才能运行作业?或者,如果您在特定分支上,是否有特定的方法来添加条件,请将此作业添加为依赖项?到目前为止,我的规则部分中有一个“需求”。审核作业仅在功能分支上运行。有人问类似的问题。
test:sauce:
...
script:
- export MASTER_URL=https://masterurlexample.io
- export TEST_PREVIEW_APP=$CI_COMMIT_REF_SLUG
- cd $MAVEN_DIRECTORY
- if [ "$CI_COMMIT_BRANCH" == "master" || "$EMULATE_BRANCH" == "master" ]; then
export TEST_PREVIEW_APP=$MASTER_URL;
needs:
fi;
- echo "Testing on $TEST_PREVIEW_APP"
- echo "starting test"
- sleep 30
- mvn -U $MAVEN_CLI_OPTS ...
rules:
- if: "$CI_COMMIT_BRANCH" != "master"
needs: [ "review "]
Run Code Online (Sandbox Code Playgroud) 我正在尝试在java中将pst时间戳转换为gmt
我有一个带有时间戳的字符串2021-03-23T22:00:00.669-07:00。我将如何处理该字符串并将其转换为 GMT 时间戳?
Run Code Online (Sandbox Code Playgroud)2021-03-24T05:03:00.669Z
我做了一些我尝试过的事情,但还没有去过任何地方
//Date date = new Date(str);
String s = str;
DateFormat pstFormat = new SimpleDateFormat();
DateFormat gmtFormat = new SimpleDateFormat();
TimeZone gmtTime = TimeZone.getTimeZone("GMT");
TimeZone pstTime = TimeZone.getTimeZone("PST");
pstFormat.setTimeZone(gmtTime);
gmtFormat.setTimeZone(pstTime);
System.out.println("GMT Time: " + pstFormat.format(s));
System.out.println("PST Time: " + gmtFormat.format(s));
Run Code Online (Sandbox Code Playgroud)
结果java.lang.IllegalArgumentException: Cannot format given Object as a Date在这一行:
System.out.println("GMT Time: " + pstFormat.format(s));
Run Code Online (Sandbox Code Playgroud)