首页 \ 问答 \ 日期格式 - momentjs - 使用区域设置语言分别提取日期和时间(Date format - momentjs - extract date and time separately using locale language)

日期格式 - momentjs - 使用区域设置语言分别提取日期和时间(Date format - momentjs - extract date and time separately using locale language)

我正在使用moment.js库我有这种格式的日期:

2014-08-07T10:00:00+02:00

我想要两个单独的值:

- Thursday, August 7 2014
- 10 am

但我也希望他们使用当地语言。 例如,如果是moment.lang(“fr”),则输出应为

- Jeudi 7 Août 2014
- 10h

我以正确的方式设置了moment.js lang。 我设法删除小时,分钟和秒(以提取第一个值):

new Date(moment.utc(date).format('LL')) //Outputs Thu Aug 07 2014 00:00:00 GMT+0200 (Paris, Madrid)

但我不知道如何提取小时和分钟 (第二个值)以及如何使用当前语言显示日期。


I am using moment.js library I have a date in this format :

2014-08-07T10:00:00+02:00

I want to have two separate values :

- Thursday, August 7 2014
- 10 am

But I also want them to be using the local language. For example, if moment.lang("fr"), the output should be

- Jeudi 7 Août 2014
- 10h

I set the moment.js lang in the correct way. I managed to remove hour,minutes and seconds (to extract the first value) :

new Date(moment.utc(date).format('LL')) //Outputs Thu Aug 07 2014 00:00:00 GMT+0200 (Paris, Madrid)

But I don't know how to extract the hour and minutes (for the second value) and how to show the date using the current language.


原文:https://stackoverflow.com/questions/25179377
更新时间:2022-10-10 15:10

最满意答案

我真的不明白为什么你需要使用2个不同的密钥库,因为密钥库配置提供了使用多个证书的可能性。

从文档引用:

要使JMeter使用多个证书,您需要确保:

  • https.use.cached.ssl.context=false在jmeter.properties或user.properties中设置

  • 您对HTTP请求使用HTTPClient 4(ADVISED)或HTTPClient 3.1(DEPRECATED SINCE 3.0)实现

如果出于任何原因,您仍然需要使用2个密钥库 ,而不是来自一个密钥库的2个证书,遗憾的是,在密钥库配置初始化之前无法执行Beanshell测试元素(或任何内容)。

但是,您应该能够强制从Beanshell脚本重新初始化。

示例代码:

import org.apache.jmeter.config.KeystoreConfig;
import org.apache.jmeter.engine.StandardJMeterEngine;
import org.apache.jmeter.testelement.TestPlan;
import org.apache.jorphan.collections.HashTree;
import org.apache.jorphan.collections.SearchByClass;

import java.lang.reflect.Field;
import java.util.Collection;


StandardJMeterEngine engine = ctx.getEngine();
Field test = engine.getClass().getDeclaredField("test");
test.setAccessible(true);
HashTree testPlanTree = (HashTree) test.get(engine);

SearchByClass keyStoreConfigs = new SearchByClass(KeystoreConfig.class);
testPlanTree.traverse(keyStoreConfigs);
Collection keystoreConfigResults = keyStoreConfigs.getSearchResults();

KeystoreConfig keystoreConfig = (KeystoreConfig)keystoreConfigResults.toArray()[0];
keystoreConfig.testStarted();

请参阅如何使用BeanShell:JMeter最喜欢的内置组件文章,以获取有关JMeter中Beanshell脚本的高级信息。


I am able to solve this issue with the below steps:

  1. Get all the certs(pfx) for the application environments
  2. Optional: Change the extension of the files to p12
  3. Set a meaningful alias names to these certs with the below command:

    keytool -changealias -alias "ExistingAliasName" -destalias "AppName_Environment" -keystore "C:\JKS\AppName_environment.p12" -storepass "StorePassword"

    Notes for step 3:

    a. It might ask to enter keypass and we can enter the store pass

    b. Even we provide upper case in alias name, the text will be converted to lower case and will be set as alias name

    c. Here I followed this alias naming convention: application name_environment name as mentioned in JMeter

  4. Import the certs into a JKS file and we can set any password to JKS and need not be same as cert. See the below command:

    keytool -importkeystore -srckeystore "C:\ JKS\ AppName _ Environment.p12" -srcstoretype pkcs12 -srcstorepass "SourceStorePasword” -destkeystore "C:\HomesiteJKS\BungalowFinal.jks" -deststoretype JKS -storepass "JKSPassword"

  5. Repeat the above step for all the remaining certs by changing the required parameter values
  6. Once we have the final JKS, we can start changing password for each of the cert in JKS and make it same as JKS(keystore) password. See the below command:

    keytool -keypasswd -alias " AppName_Environment" -keystore “C:\JKS\Final.jks"

    Note for step 6: It will ask you to enter keystore password, existing cert password, new password and repeat new password

  7. Repeat this step for all the cert entries of JKS file to have JKS password for all the certs
  8. Now we can use this file and add below entries in system.properties of JMeter: javax.net.ssl.keyStore=C:/JKS/Final.jks

    javax.net.ssl.keyStorePassword=JKSPassword

  9. Add the below entry either in user.properties or jmeter.properties of JMeter, which will allow us to use multiple certs from JKS file:

    https.use.cached.ssl.context=false

  10. Change Http Request implementation to HttpClient4
  11. Add Keystore configuration element to JMeter test with the below values:

    a. Preload: True

    b. Variable name holding certificate alias: CertAlias

    c. Alias Start index: 0

    d. Alias End index: 10000

  12. JMeter user defined variables must have CertAlias with the required alias name
  13. All set and we should be able to run the script on different application environments by loading particular cert with alias name

相关问答

更多

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)