本文整理汇总了Scala中java.text.DecimalFormatSymbols类的典型用法代码示例。如果您正苦于以下问题:Scala DecimalFormatSymbols类的具体用法?Scala DecimalFormatSymbols怎么用?Scala DecimalFormatSymbols使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DecimalFormatSymbols类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: CmdType
//设置package包名称以及导入依赖的类
package libgcode
import java.text.{DecimalFormat,DecimalFormatSymbols}
import java.util.Locale
object CmdType extends Enumeration {
type CmdType = Value
val G, M, O, T, Empty = Value
}
object ParamType extends Enumeration {
type ParamType = Value
val A, B, C, D, E, F, H, I, J, K, L, P, Q, R, S, T, X, Y, Z = Value
}
import CmdType._
import ParamType.{T => PT, _}
// each line is a command
case class Command( ctype: CmdType, // Empty means it is a comment only
code: Seq[Int], // code X.Y corresponds to Seq(X, Y)
parameters: Seq[Param], // parameters
line: Option[Int], // line number (optional)
comment: Option[String]) { // trailing comment
def replaceComment(c: Option[String]) = {
if (c == comment) this
else Command(ctype, code, parameters, line, comment)
}
}
sealed abstract class Param
case class ParamT(ptype: ParamType) extends Param {
override def toString = ptype.toString
}
case class RealParam(ptype: ParamType, value: Double) extends Param {
assert(RealParam.is(ptype), ptype + " is not a real valued parameter")
override def toString = ptype.toString + RealParam.format(value)
}
case class IntParam(ptype: ParamType, value: Int) extends Param {
assert(IntParam.is(ptype), ptype + " is not an integer valued parameter")
override def toString = ptype.toString + value
}
object RealParam {
val types = Set(A, B, C, D, E, F, H, I, J, K, Q, R, X, Y, Z)
def is(t: ParamType) = types(t)
protected val df = new DecimalFormat("0", DecimalFormatSymbols.getInstance(Locale.ENGLISH))
df.setMaximumFractionDigits(340)
def format(d: Double) = df.format(d)
}
object IntParam {
val types = Set(L, P, S, PT)
def is(t: ParamType) = types(t)
}
示例2: DemoApp
//设置package包名称以及导入依赖的类
package demo
import java.text.DecimalFormatSymbols
import java.util.Locale
import scala.scalajs.js
import scala.scalajs.js.annotation.JSExport
import locales.LocaleRegistry
import locales.cldr.data.fi_FI
@JSExport("DemoApp")
object DemoApp extends js.JSApp {
@scala.scalajs.js.annotation.JSExport
override def main(): Unit = {
// Minimal demo used for sanity checks and for size improvements
LocaleRegistry.installLocale(fi_FI)
val tag = fi_FI.languageTag
val dfs = DecimalFormatSymbols.getInstance(Locale.forLanguageTag(tag))
println(fi_FI.languageTag)
println("NaN: " + dfs.getNaN)
}
}