自定义函数-Fx.utils

2020-12-29 10:14:00 639 本站

      Fx.utils:工具类相关的API

1、从html中提取纯文本-htmlParseText

     定义:Fx.utils.htmlParseText(<String html>)

参数说明
html提取html内容

     data返回值类型:Stirng(提取后的文本)

     例:

def ret = Fx.utils.htmlParseText('<div class="drop-content-item"><div class="drop-box"> <div class="drop-box-item drop-box-item2" style="border: none"><p><img class="img-icon"style="width:20px;"src="https://www.fxiaoke.com/ap/wp-content/uploads/2020/05/icon-live.png"><ahref="/ap/live/">直播视频</a></p><span>RM公开课、hth手机版下载
使用技巧、数字化转型策略及行业应用最新实践等视频内容</span></div>')

2、汉字转拼音-toPinyin

     定义:Fx.utils.toPinyin(<String chinese>)

参数说明
chinese汉字

     data返回值类型:Stirng(汉字的拼音)

     例:

def ret = Fx.utils.toPinyin("测试");

3、数组拆分-listPartition

     定义:Fx.utils.listPartition(<List list>,<int size>)

参数说明
list拆分的数组
size拆分后每个数组的长度

     data返回值类型:List(按照指定大小拆分的数组集合)      返回值例:

[[1,2,3,],[4,5,6],[7,8,9]]

     调用例: List original = [1,2,3,4,5,6,7,8,9] List partition = Fx.utils.listPartition(original,3)


4、字符串转byte数组/byte数组转字符串-toUTF8Bytes/toUTF8String

  • 字符串转byte数组:Fx.utils.toUTF8Bytes(String content)

  • byte数组转字符串:Fx.utils.toUTF8String(byte[] bytes)

     data返回值类型:String

     例:

byte[] bytes = Fx.utils.toUTF8Bytes("测试")
String content = Fx.utils.toUTF8String(bytes)

5、返回指定年月的天数-daysInMonth

  •  定义:Fx.utils.daysInMonth(<Integer Year>,<Integer Month>)

     data返回值类型:Integer

     例:

Fx.utils.daysInMonth(2020,2) //返回29

6、返回指定年是否是闰年isLeapYear

  •  定义:Fx.utils.isLeapYear(<Integer Year>)

     data返回值类型:Boolean

     例:

Fx.utils.isLeapYear(2020) //返回true

7、获取终端的请求来源-getRequestSource

  •  定义:Fx.utils.getRequestSource()

     data返回值类型:终端名称

     例:

```
//获取函数执行时的来源,返回一个字符串
String source = Fx.utils.getRequestSource()
//Android 安卓
//IOS   ios
//WX   微信
//WEB   网页
//FSBrowser 分享客户端
//如果查询不到返回空字符串(例如流程后面),目前只能在终端直接触发函数时可以获取到(例如点击按钮)
```



内容来源于互联网,如有侵权,请联系客服删除处理。
在线咨询 拨打电话
Baidu
map