首页 \ 问答 \ 如何在Java中将编辑框从几分钟更改为几小时(How to change an editbox from minutes to hours in Java)

如何在Java中将编辑框从几分钟更改为几小时(How to change an editbox from minutes to hours in Java)

我有一个变量,它是一个包含三分钟值的整数数组( intArr )。 然后我有三个编辑框( e1e2e3 ),其中e1取值intArr [0],e2取值intArr [1],e3取值intArr [2]。 我还有一个单选按钮(可以选择“ 以分钟显示编辑框时间 ”或“ 以秒为单位显示编辑框时间 ”)连接到变量。

如何将编辑框中的时间(最初以分钟为单位)更改为小时,或者以相反的方式将时间从几小时更改为几分钟,具体取决于所选的单选按钮?


I have a variable that is an integer array (intArr) containing three minute values. Then I have three edit boxes (e1, e2, e3), where e1 takes value intArr[0], e2 takes value intArr[1] and e3 takes value intArr[2]. I also have a radio button (one can either choose "Show edit box time in minutes" or "Show edit box time in seconds") connected to a variable.

How do I change the time in the edit boxes (which initially are in minutes) into hours, or in the opposite way from hours to minutes depending on which radio button has been chosen?


原文:https://stackoverflow.com/questions/21708029
更新时间:2023-06-08 08:06

最满意答案

要使用cut提取arg1值:

$ cut -d',' -f 2 sendmail.log | cut -d'=' -f 2
[108.188.182.85]

使用cut提取relay值:

$ cut -d',' -f 4 sendmail.log | cut -d'=' -f 2
108-188-182-85.biz.bhn.net [108.188.182.85] (may be forged)

两个值arg1relay ,在同一行中,用分号分隔; ,使用awk

$ awk 'BEGIN {FS=",";OFS=";"}{split($2,a,"=");split($4,b,"=");print a[2],b[2]}' sendmail.log
[108.188.182.85];108-188-182-85.biz.bhn.net [108.188.182.85] (may be forged)

希望能帮助到你!


To extract arg1 value using cut:

$ cut -d',' -f 2 sendmail.log | cut -d'=' -f 2
[108.188.182.85]

To extract relay value using cut:

$ cut -d',' -f 4 sendmail.log | cut -d'=' -f 2
108-188-182-85.biz.bhn.net [108.188.182.85] (may be forged)

Both values arg1 and relay, in the same line, separated by a semicolon ;, using awk:

$ awk 'BEGIN {FS=",";OFS=";"}{split($2,a,"=");split($4,b,"=");print a[2],b[2]}' sendmail.log
[108.188.182.85];108-188-182-85.biz.bhn.net [108.188.182.85] (may be forged)

Hope It Helps!

相关问答

更多
  • 为此使用负面预测。 (?!foo123).+ 匹配除foo123以外的任何字符串 如果你想匹配空字符串,使用(?!foo123).* 在你的情况(根据评论)所需的正则表达式是(?!P[0-9]{1,}).+ 。 它匹配P和123 ,但不匹配P123 。 Use negative lookahead for this. (?!foo123).+ matches any string except foo123 If you want to match empty string also, use (?!f ...
  • 尝试这个正则表达式: \b(\w+)\s+\1\b 这里\b是一个单词边界, \1引用了第一组的捕获匹配。 Try this regular expression: \b(\w+)\s+\1\b Here \b is a word boundary and \1 references the captured match of the first group.
  • 放在 。 并将以下数字放入可选组中,并使尾随数字的最小长度为1 \\d+(\\.\\d{1,2})? Put the . and the following digits into an optional group and make the minimum length of the trailing digits 1 \\d+(\\.\\d{1,2})?
  • 你的问题是可能没有设置的g模式。 如果你设置这个全局模式,你会看到预期的子串是匹配的 。 这个(0*)(\d*)匹配但在g模式下返回两个以上的组,因为两个模式都是包含零长度匹配的 *量化。 +量词表示至少一次出现前一个标记,因此它会查找其存在是必须的事情。 说了这么多,它不会返回零长度匹配。 您的第三次尝试(0*)(\d*$)与+量词相同,因为零长度匹配不会比满足输入字符串末尾的数字更早发生。 然而,使用这个正则表达式,当g模式打开时,最后会有一个零长度匹配。 Your problem is with g ...
  • 最好依靠这种东西的框架 。 try { address = new MailAddress(address).Address; } catch(FormatException) { //address is invalid } Best to rely on the framework for this kind of stuff. try { address = new MailAddress(address).Address; } catch(FormatException) ...
  • 为了: ^ - 匹配输入的开始 \d - 一个数字(0-9) [0,1]+ - 一个或多个出现的字符0 ,,或1 - 但请参阅下面的注释,这可能不是作者的意思 ( - 捕获组的开始 \. - 文字. (没有反斜杠,这将意味着一些特别的东西) \d - 一位数字 [1,4] - 字符1 ,或4 - 但请参阅下面的注释,这可能不是作者的意思 ) - 捕获组的结束 ? - 确定整个捕获组是可选的 (零次或一次) $ - 匹配输入的结尾 重新[0,1]+和[1,4] ,该表达式可能应该有{0,1}和{1,4} ,这 ...
  • 大卫,原因(]*>)>是你有一个小错字。 你看,该表达式尝试匹配两个结束> :仔细查看结束>)> 。 例如,它会匹配>但不会 要匹配开头跨度,请确保只有一个> 。 有了所有关于使用正则表达式来匹配html的免责声明,这个正则表达式将会: ]*> 如果您有时期望SPAN ,请确保使其不区分大小写。 只有你有时间:一个额外的蓬勃发展 在评论中,@ David Ehrmann指出上面的正则表达式将匹配
  • 方式集定义了很多纬度,还有一个自己的概念: [+-^] 这意味着ASCII表格中+和^之间的所有字符,这是很多字符,包括<和>以及所有字母。 要解决这个问题: [\+\-\^] 逃避任何不规则的事情通常是一个好主意,即使不是绝对必要的。 The way sets are defined has a lot of latitude, and a metasyntax of its own: [+-^] This means all the characters between + and ^ in th ...
  • 要使用cut提取arg1值: $ cut -d',' -f 2 sendmail.log | cut -d'=' -f 2 [108.188.182.85] 使用cut提取relay值: $ cut -d',' -f 4 sendmail.log | cut -d'=' -f 2 108-188-182-85.biz.bhn.net [108.188.182.85] (may be forged) 两个值arg1和relay ,在同一行中,用分号分隔; ,使用awk : $ awk 'BEGIN {FS ...
  • ^ :开始行 (?:....) :非捕获组(与(....)相反,捕获组) \, ,:相当于, ( \确实是不必要的) 因此:行的开始( ^ ),然后恰好是一个( (?:....){1} ):在第一组中捕获的任意数量的非逗号( [^,]* )( (....) )和一个可选的逗号( ,? )。 ^: start of line (?:....): non-capturing group (as opposed to (....), capturing group) \,: equivalent to , (\ ...

相关文章

更多

最新问答

更多
  • 您如何使用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)