当前位置: 首页>>代码示例>>Scala>>正文


Scala DecimalFormatSymbols类代码示例

本文整理汇总了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)
} 
开发者ID:dzufferey,项目名称:libgcode,代码行数:59,代码来源:GCode.scala

示例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)
  }
} 
开发者ID:cquiroz,项目名称:scalajs-locales-demo,代码行数:24,代码来源:DemoApp.scala


注:本文中的java.text.DecimalFormatSymbols类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。