本文整理汇总了Scala中java.text.DateFormat类的典型用法代码示例。如果您正苦于以下问题:Scala DateFormat类的具体用法?Scala DateFormat怎么用?Scala DateFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DateFormat类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: toStringForLocale
//设置package包名称以及导入依赖的类
package edu.neu.coe.scala
package scaladate
import java.util.{Date,Locale}
import java.text.DateFormat
import java.text.DateFormat._
trait LocaleDependent {
def toStringForLocale(implicit locale: Locale): String
}
case class ScalaDate(date: Date) extends LocaleDependent {
import ScalaDate.locale
def toStringForLocale(implicit locale: Locale): String = getDateInstance(LONG,locale) format date
override def toString: String = toStringForLocale(locale)
}
object ScalaDate {
def apply(): ScalaDate = ScalaDate(new Date)
implicit def locale = Locale.FRANCE
def main(args: Array[String]): Unit = {
println(apply())
}
}
开发者ID:menezesl,项目名称:Scala-repo,代码行数:25,代码来源:LocaleDependent.scala
示例2: LogProcessor
//设置package包名称以及导入依赖的类
package executable
import java.io.FileWriter
import java.text.{DateFormat, SimpleDateFormat}
import java.util.Date
import java.util.concurrent.LinkedBlockingDeque
import exonode.clifton.config.ProtocolConfig
import exonode.clifton.node.SpaceCache
import exonode.clifton.node.entries.ExoEntry
import exonode.clifton.signals.Log.LogType
object LogProcessor extends Thread {
setDaemon(true)
private val LogFile: String = "log.cfv"
private val IntervalTime = 1000
private val MaxLogsCalls = 20
private val logTemplate = ExoEntry[LogType](ProtocolConfig.LogMarker, null)
private val dateFormat: DateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss")
private val logs = new LinkedBlockingDeque[LogType]()
private val analyseFile = new SystemAnalyser(2, logs)
override def run(): Unit = {
val space = SpaceCache.getSignalSpace
println("LogProcessor Started...")
analyseFile.start()
while (true) {
val res: Iterable[ExoEntry[LogType]] = space.takeMany(logTemplate, MaxLogsCalls)
if (res.nonEmpty) {
val file: FileWriter = new FileWriter(LogFile, true)
val date: Date = new Date()
for (exoEntry <- res) {
val log = exoEntry.payload
logs.push(log)
file.write(dateFormat.format(date) + ProtocolConfig.LogSeparator + log.logType +
ProtocolConfig.LogSeparator + log.message + "\n")
}
file.close()
} else
Thread.sleep(IntervalTime)
}
}
def main(args: Array[String]): Unit = {
if (args.length > 0)
SpaceCache.signalHost = args(0)
LogProcessor.start()
LogProcessor.join()
}
}
开发者ID:exocute,项目名称:Toolkit,代码行数:57,代码来源:LogProcessor.scala
示例3: CommonDateFormat
//设置package包名称以及导入依赖的类
package com.avsystem.scex.util
import java.text.{DateFormat, SimpleDateFormat}
object CommonDateFormat {
private val dateFormatTL = new ThreadLocal[DateFormat] {
override def initialValue(): DateFormat = {
val df = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss")
df.setLenient(false)
df
}
}
def get: DateFormat = dateFormatTL.get
}
开发者ID:AVSystem,项目名称:scex,代码行数:16,代码来源:CommonDateFormat.scala
示例4: Employee
//设置package包名称以及导入依赖的类
package models
import java.text.{SimpleDateFormat, DateFormat}
import java.util.Date
import com.google.inject.ImplementedBy
import scala.collection.mutable.ListBuffer
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
case class Employee(name:String,address:String,dob:Date,doj:Date,designation:String)
@ImplementedBy(classOf[EmployeeService])
trait EmployeeModel {
def getAllEmployee:Future[ListBuffer[Employee]]
def getEmployeeName(ename:String):Future[ListBuffer[Employee]]
def addEmployee(ename:String,eaddress:String,edob:Date,edoj:Date,edesig:String):Future[Boolean]
def deleteEmployee(ename:String):Boolean
def updateEmployee(ename:String,eaddress:String,edob:Date,edoj:Date,edesig:String):Boolean
}
class EmployeeService extends EmployeeModel{
// val empList:ListBuffer[Employee]=ListBuffer(Employee("Pallavi","Ashok Vihar",new Date(1992-3-9),new Date(2016-3-9),"Manager"))
val empList:ListBuffer[Employee]=ListBuffer(Employee("Seema","Ashok Vihar",new SimpleDateFormat("yyyy-MMM-dd").parse("1992-Mar-09"),new SimpleDateFormat("yyyy-MMM-dd").parse("2016-Jan-21"),"Software Consultant"),Employee("Himani ","Lakshmi Nagar",new SimpleDateFormat("yyyy-MMM-dd").parse("1992-May-09"),new SimpleDateFormat("yyyy-MMM-dd").parse("2016-Jan-21"),"Software Consultant"),Employee("Pallavi","Ashok Vihar",new SimpleDateFormat("yyyy-MMM-dd").parse("1992-Mar-09"),new SimpleDateFormat("yyyy-MMM-dd").parse("2016-Jan-21"),"Software Consultant"))
def getAllEmployee:Future[ListBuffer[Employee]]=Future{
empList
}
def getEmployeeName(ename:String):Future[ListBuffer[Employee]]=Future{
empList.filter(emp=>emp.name==ename)
}
def addEmployee(ename:String,eaddress:String,edob:Date,edoj:Date,edesig:String):Future[Boolean] =Future {
empList.append(Employee(ename,eaddress,edob,edoj,edesig))
true
}
def deleteEmployee(ename:String):Boolean={
if(empList.map(_.name).contains(ename)) {
empList.remove(empList.map(_.name).indexOf(ename))
true
}
false
}
def updateEmployee(ename:String,eaddress:String,edob:Date,edoj:Date,edesig:String):Boolean={
if(empList.map(_.name).contains(ename)) {
empList.update(empList.map(_.name).indexOf(ename),Employee(ename,eaddress,edob,edoj,edesig))
true
}
false
}
}
开发者ID:himani1,项目名称:play2Rough,代码行数:61,代码来源:EmployeeModel.scala
示例5: LogFile
//设置package包名称以及导入依赖的类
package se.lth.immun.app
import java.io.File
import java.io.PrintWriter
import java.text.DateFormat
import java.util.Date
class LogFile(
var name:String,
var dir:String = "log"
) {
var dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM)
var folder = new File(dir)
var file = new File(dir, name + ".log")
var writer:PrintWriter = null
if (!folder.exists)
try { folder.mkdir }
catch { case _:Throwable => println("WARNING: couldn't create log file folder")}
if (folder.exists && file.exists)
try { file.delete }
catch { case _:Throwable => println("WARNING: couldn't delete old log file")}
try {file.createNewFile}
catch {case _:Throwable => println("WARNING: couldn't create new log file")}
if (file.exists)
writer = new PrintWriter(file)
write("===== " + name + " =====\n")
def write(mess:Any) = {
if (writer != null) {
mess match {
case str:String => writer.write("[" + dateFormat.format(new Date()) + "]" + mess + "\n")
case e:Exception => e.printStackTrace(writer)
}
writer.flush()
}
}
}
开发者ID:fickludd,项目名称:anubis,代码行数:47,代码来源:LogFile.scala
示例6: TimeColumn
//设置package包名称以及导入依赖的类
package views
import javafx.scene.control._
import javafx.scene.control.cell._
import javafx.util.Callback
import java.text.DateFormat
import fxlog.field.Time
import fxlog.model.Record
class TimeColumn extends TableColumn[Record, Time] {
val timeFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM)
setText("Time")
setMinWidth(80)
setCellValueFactory(new PropertyValueFactory[Record, Time]("time"))
setCellFactory(new Callback[TableColumn[Record, Time], TableCell[Record, Time]] {
override def call(col: TableColumn[Record, Time]) = new TableCell[Record, Time] {
override def updateItem(item: Time, empty: Boolean) {
if(item != null) setText(timeFormat.format(item.getValue))
}
}
})
}
开发者ID:nextzlog,项目名称:pafe,代码行数:27,代码来源:TimeColumn.scala
示例7: Time
//设置package包名称以及导入依赖的类
package com.joescii.scalaz.stream
import java.text.{DateFormat, SimpleDateFormat}
import java.util.{Calendar, TimeZone}
object Time {
val utc = TimeZone.getTimeZone("UTC")
def dateFormat(pattern: String): DateFormat =
new SimpleDateFormat(pattern) !! (_.setTimeZone(utc))
def logDateFormat = Time.dateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS")
def roundTime(c: Calendar, bucketSize: Int): Calendar = {
val second = c.get(Calendar.SECOND) / bucketSize * bucketSize
c.clone().asInstanceOf[Calendar]
.!!(_.set(Calendar.SECOND, second))
.!!(_.set(Calendar.MILLISECOND, 0))
}
}
开发者ID:joescii,项目名称:scalaz-stream-elb-logs,代码行数:21,代码来源:Time.scala
注:本文中的java.text.DateFormat类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论