Round stock change percent value
This commit is contained in:
parent
5c3eaf232d
commit
066e3f81e9
2 changed files with 5 additions and 3 deletions
|
@ -46,6 +46,7 @@ import org.pircbotx.hooks.types.GenericMessageEvent
|
|||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.IOException
|
||||
import java.math.RoundingMode
|
||||
import java.net.URL
|
||||
import java.time.Instant
|
||||
import java.time.ZoneId
|
||||
|
@ -180,7 +181,8 @@ class StockQuote2 : AbstractModule() {
|
|||
)
|
||||
add(
|
||||
NoticeMessage(
|
||||
"Change: ".padEnd(pad).prependIndent() + change + " [$changePercent%]"
|
||||
"Change: ".padEnd(pad).prependIndent() + change
|
||||
+ " [${changePercent.setScale(2, RoundingMode.DOWN)}%]"
|
||||
)
|
||||
)
|
||||
add(
|
||||
|
@ -264,7 +266,7 @@ class StockQuote2 : AbstractModule() {
|
|||
val name = result.getString("description")
|
||||
|
||||
add(
|
||||
NoticeMessage("${symbol.bold()}: $name".prependIndent())
|
||||
NoticeMessage("${symbol.bold().padEnd(10)} $name".prependIndent())
|
||||
)
|
||||
|
||||
if (i >= 4) {
|
||||
|
|
|
@ -161,7 +161,7 @@ class StockQuote2Test : LocalProperties() {
|
|||
|
||||
var hasGoog = false
|
||||
for (msg in messages) {
|
||||
if (msg.msg.matches("\\s+\u0002GOOG\u0002: .*".toRegex())) {
|
||||
if (msg.msg.matches("\\s+\u0002GOOG\u0002\\s+.*".toRegex())) {
|
||||
hasGoog = true
|
||||
break
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue