net.liftweb.util.TimeHelpers

object TimeHelpers

object TimeHelpers

 extends TimeHelpers with ControlHelpers


The TimeHelpers object extends the TimeHelpers. It can be imported to access all of the trait functions.


Companion: TimeHelpers

Source: TimeHelpers.scala(28)

 Constructors

def this

 Fields

currentYear.. def currentYear
[details]
return
- the current year
Int TimeHelpers
dateFormatter.. def dateFormatter
[details]
return
- a standard format for the date yyyy/MM/dd
SimpleDateFormat TimeHelpers
dayNow.. def dayNow
[details]
deprecated
- use today instead
return
- the current Day as a Date object
Date TimeHelpers
daysSinceEpoch.. def daysSinceEpoch
[details]
return
- the number of days since epoch
Long TimeHelpers
formattedDateNow.. def formattedDateNow
[details]
return
- today's date formatted as yyyy/MM/dd
String TimeHelpers
formattedTimeNow.. def formattedTimeNow
[details]
return
- now's time formatted as HH:mm zzz
String TimeHelpers
hourFormat.. val hourFormat
[details]
return
- a standard format HH:mm:ss
SimpleDateFormat TimeHelpers
internetDateFormatter.. def internetDateFormatter
[details]
return
- a formatter for internet dates including: the day of week, the month, day of month, time and time zone
SimpleDateFormat TimeHelpers
millis.. def millis
[details]
return
- the current number of millis: System.currentTimeMillis
Long TimeHelpers
now.. def now
[details]
return
- the date object for now
Date TimeHelpers
nowAsInternetDate.. def nowAsInternetDate
[details]
return
- the current time as an internet date
String TimeHelpers
timeFormatter.. def timeFormatter
[details]
return
- a format for the time which includes the TimeZone: HH:mm zzz
SimpleDateFormat TimeHelpers
timeNow.. def timeNow
[details]
deprecated
- use now instead
return
- the current time as a Date object
Date TimeHelpers
today.. def today
[details]
return
- the Calendar object for today (the TimeZone is the local TimeZone). Its time is 00:00:00.000
Calendar TimeHelpers
utc.. val utc
The UTC TimeZone
TimeZone TimeHelpers

 Methods

!=.. final def !=(arg0 : Any) Boolean Any
!=.. final def !=(arg0 : Object) Boolean AnyRef
==.. final def ==(arg0 : Object) Boolean AnyRef
==.. final def ==(arg0 : Any) Boolean Any
^.. def ^[T](i : T*)
This operator transforms its arguments into a List [details]
return
- the list of arguments passed as varargs
List[T] ClassHelpers
asInstanceOf.. final def asInstanceOf[T0] T0 Any
boxParseInternetDate.. def boxParseInternetDate(dateString : String)
[details]
return
- a date from a string using the internet format. Return the Epoch date if the parse is unsuccesfull
Box[Date] TimeHelpers
calcTime.. def calcTime[T](f : => T)
[details]
return
- the time taken to evaluate f in millis and the result
(Long, T) TimeHelpers
callableMethod_?.. def callableMethod_?(meth : Method)
[details]
return
- true if the method is public and has no parameters
Boolean ClassHelpers
camelCase.. def camelCase(name : String) String ClassHelpers
camelCaseMethod.. def camelCaseMethod(name : String) String ClassHelpers
classHasControllerMethod.. def classHasControllerMethod(clz : Class[Any], name : String)
Check that the method 'name' is callable for class 'clz' [details]
param
name - name of the method to test
clz - the class supposed to own the method
return
- true if the method exists on the class and is callable
Boolean ClassHelpers
classHierarchy.. def classHierarchy(in : Class[Any]) List[Class[Any]] ClassHelpers
clone.. protected def clone Object AnyRef
containsClass.. def containsClass[C](clz : Class[C], toMatch : List[Class[Any]])
Is the clz an instance of (assignable from) any of the classes in the list [details]
param
toMatch - the list of classes to match against
clz - the class to test
return
- true if clz is assignable from any of the matching classes
Boolean ClassHelpers
createInvoker.. def createInvoker[C <: Object](name : String, on : C)
Create a function (the 'invoker') which will trigger any public, parameterless method That function will throw the cause exception if the method can't be invoked [details]
param
on - instance whose method must be invoked
clz - class whose method should be invoked
return
- Empty if instance is null or Full(invoker)
Box[() => Box[Any]] ClassHelpers
day.. def day(in : Date)
[details]
return
- the day of month corresponding to the input date (1 based)
Int TimeHelpers
days.. def days(in : Long)
[details]
return
- the number of millis corresponding to 'in' days
Long TimeHelpers
eq.. final def eq(arg0 : Object) Boolean AnyRef
equals.. def equals(arg0 : Any) Boolean AnyRef
finalize.. protected def finalize Unit AnyRef
findClass.. def findClass[C <: Object](name : String, where : List[String], modifiers : List[(String) => String], targetType : Class[C])
General method to in find a class according to its name, a list of possible packages, a list of functions modifying the given name create a target name to look for (e [details]
g: 'name' is hello_world and the target name may be 'HelloWorld'). @parameter name name of the class to find @parameter where list of package names which may contain the class @parameter modifiers list of functions that modify the 'name' of the class (e.g., leave it alone, make it camel case, etc.) @parameter targetType optional expected type which the retrieved class should conform to
return
- a Box, either containing the found class or an Empty can.
Box[Class[C]] ClassHelpers
findClass.. def findClass(name : String, where : List[String], modifiers : List[(String) => String])
General method to in find a class according to its name, a list of possible packages and a list of functions modifying the given name create a target name to look for (e [details]
g: 'name' is hello_world and the target name may be 'HelloWorld'). @parameter name name of the class to find @parameter where list of package names which may contain the class @parameter modifiers list of functions that modify the 'name' of the class (e.g., leave it alone, make it camel case, etc.)
return
- a Box, either containing the found class or an Empty can.
Box[Class[Object]] ClassHelpers
findClass.. def findClass(where : List[(String, List[String])])
Find a class given a list of possible names and corresponding packages, turning underscored names to CamelCase if necessary @parameter where list of pairs (name, package names) which may contain the class [details]
return
- a Box, either containing the found class or an Empty can.
Box[Class[Object]] ClassHelpers
findClass.. def findClass[C <: Object](name : String, where : List[String], targetType : Class[C])
Find a class given its name and a list of packages, turning underscored names to CamelCase if necessary [details]
@parameter name name of the class to find @parameter where list of package names which may contain the class @parameter targetType optional expected type which the retrieved class should conform to
return
- a Box, either containing the found class or an Empty can.
Box[Class[C]] ClassHelpers
findClass.. def findClass(name : String, where : List[String])
Find a class given its name and a list of packages, turning underscored names to CamelCase if necessary [details]
@parameter name name of the class to find @parameter where list of package names which may contain the class
return
- a Box, either containing the found class or an Empty can.
Box[Class[Object]] ClassHelpers
findType.. def findType[C <: Object](name : String, where : List[String])(implicit m : Manifest[C])
Find a class given its type, its name and a list of packages, turning underscored names to CamelCase if necessary [details]
@parameter C type of the class to find @parameter name name of the class to find @parameter where list of package names which may contain the class
return
- a Box, either containing the found class or an Empty can.
Box[Class[C]] ClassHelpers
findType.. def findType[C <: Object](where : List[(String, List[String])])(implicit m : Manifest[C])
Find a class given its type, a list of possible names and corresponding packages, turning underscored names to CamelCase if necessary @parameter C type of the class to find @parameter where list of pairs (name, package names) which may contain the class [details]
return
- a Box, either containing the found class or an Empty can.
Box[Class[C]] ClassHelpers
findType.. def findType[C <: Object](name : String, where : List[String], modifiers : List[(String) => String])(implicit m : Manifest[C])
General method to in find a class according to its type, its name, a list of possible packages and a list of functions modifying the given name create a target name to look for (e [details]
g: 'name' is hello_world and the target name may be 'HelloWorld'). @parameter C type of the class to find @parameter name name of the class to find @parameter where list of package names which may contain the class @parameter modifiers list of functions that modify the 'name' of the class (e.g., leave it alone, make it camel case, etc.)
return
- a Box, either containing the found class or an Empty can.
Box[Class[C]] ClassHelpers
getClass.. final def getClass Class[Any] AnyRef
hashCode.. def hashCode Int AnyRef
hourFormat.. def hourFormat(in : Date)
[details]
return
- the formatted time for a given Date
String TimeHelpers
hours.. def hours(in : Long)
[details]
return
- the number of millis corresponding to 'in' hours
Long TimeHelpers
instantiate.. def instantiate[C](clz : Class[C])
Create a new instance of a class [details]
return
- a Full can with the instance or a Failure if the instance can't be created
Box[C] ClassHelpers
intToTimeSpan.. implicit def intToTimeSpan(in : Int)
transforms an int to a TimeSpan object [details]
Usage: 3000 returns a TimeSpan of 3000L millis
TimeSpan TimeHelpers
intToTimeSpanBuilder.. implicit def intToTimeSpanBuilder(in : Int)
transforms an int to a TimeSpanBuilder object [details]
Usage: 3.seconds returns a TimeSpan of 3000L millis
TimeSpanBuilder TimeHelpers
invokeControllerMethod.. def invokeControllerMethod(clz : Class[Any], meth : String)
Invoke a controller method (parameterless, public) on a class [details]
param
name - name of the method to invoke
clz - the class owning the method
return
- the result of the method invocation or throws the root exception causing an error
Any ClassHelpers
invokeMethod.. def invokeMethod[C](clz : Class[C], inst : Object, meth : String, params : Array[Object])
Invoke the given method for the given class, with some parameters [details]
Tries the method name, then the method as a CamelCased name and the method as a camelCased name The class is not instanciated if the method is static, otherwise the passed instance is used
param
params - parameters to pass to the method
inst - instance of the class who method should be invoked, if the method is not static
meth - method to invoke
clz - class whose method should be invoked
return
- a Box containing the value returned by the method
Box[Any] ClassHelpers
invokeMethod.. def invokeMethod[C](clz : Class[C], inst : Object, meth : String)
Invoke the given method for the given class, with no params [details]
The class is not instanciated if the method is static, otherwise the passed instance is used
param
inst - instance of the class who method should be invoked, if the method is not static
meth - method to invoke
clz - class whose method should be invoked
return
- a Box containing the value returned by the method
Box[Any] ClassHelpers
invokeMethod.. def invokeMethod[C](clz : Class[C], inst : Object, meth : String, params : Array[Object], ptypes : Array[Class[Any]])
Invoke the given method for the given class, with some parameters and their types Tries the method name, then the method as a CamelCased name and the method as a camelCased name The class is not instanciated if the method is static, otherwise the passed instance is used [details]
param
params - parameters to pass to the method
inst - instance of the class who method should be invoked, if the method is not static
meth - method to invoke
ptypes - list of types of the parameters
clz - class whose method should be invoked
return
- a Box containing the value returned by the method
Box[Any] ClassHelpers
isInstanceOf.. final def isInstanceOf[T0] Boolean Any
logTime.. def logTime[T](msg : String)(f : => T)
Log a message with the time taken in millis to do something and retrun the result [details]
return
- the result
T TimeHelpers
longToTimeSpan.. implicit def longToTimeSpan(in : Long)
transforms a long to a TimeSpan object [details]
Usage: 3000L returns a TimeSpan of 3000L millis
TimeSpan TimeHelpers
longToTimeSpanBuilder.. implicit def longToTimeSpanBuilder(in : Long)
transforms a long to a TimeSpanBuilder object [details]
Usage: 3L.seconds returns a TimeSpan of 3000L millis
TimeSpanBuilder TimeHelpers
millisToDays.. def millisToDays(millis : Long)
[details]
return
- the number of days since epoch converted from millis
Long TimeHelpers
minutes.. def minutes(in : Long)
[details]
return
- the number of millis corresponding to 'in' minutes
Long TimeHelpers
month.. def month(in : Date)
[details]
return
- the month corresponding to today (0 based, relative to UTC)
Int TimeHelpers
ne.. final def ne(arg0 : Object) Boolean AnyRef
notify.. final def notify Unit AnyRef
notifyAll.. final def notifyAll Unit AnyRef
parseInternetDate.. def parseInternetDate(dateString : String)
[details]
return
- a date from a string using the internet format. Return the Epoch date if the parse is unsuccesfull
Date TimeHelpers
seconds.. def seconds(in : Long)
[details]
return
- the number of millis corresponding to 'in' seconds
Long TimeHelpers
synchronized.. final def synchronized[T0](arg0 : T0) T0 AnyRef
time.. def time(when : Long)
alias for new Date(millis)
Date TimeHelpers
toCalendarExtension.. implicit def toCalendarExtension(c : Calendar)
implicit def used to add the setXXX methods to the Calendar class
CalendarExtension TimeHelpers
toDate.. def toDate(in : Any)
[details]
return
- a Full(date) or a failure if the input couldn't be translated to date (or Empty if the input is null)
Box[Date] TimeHelpers
toDateExtension.. implicit def toDateExtension(d : Date)
implicit def used to add the noTime method to the Date class
DateExtension TimeHelpers
toInternetDate.. def toInternetDate(in : Date)
[details]
return
- a date formatted with the internet format
String TimeHelpers
toInternetDate.. def toInternetDate(in : Long)
[details]
return
- a date formatted with the internet format (from a number of millis)
String TimeHelpers
toString.. def toString String AnyRef
tryo.. def tryo[T](onError : (Throwable) => Unit)(f : => T)
Wraps a "try" block around the function f and trigger a callback function if an exception is thrown [details]
param
f - - the block of code to evaluate
onError - - an optional callback function that will use the thrown exception as a parameter
return
-
  • Full(result of the evaluation of f) if f doesn't throw any exception
  • a Failure if f throws an exception
Box[T] ControlHelpers
tryo.. def tryo[T](ignore : Class[Any])(f : => T)
Wraps a "try" block around the function f [details]
Takes only one Class of exception to ignore
param
f - - the block of code to evaluate
ignore - - a single exception classes to ignore. A thrown exception will be ignored if it is assignable from this class.
return
-
  • Full(result of the evaluation of f) if f doesn't throw any exception
  • a Failure if f throws an exception
  • Empty if the exception class is in the ignore list
Box[T] ControlHelpers
tryo.. def tryo[T](handler : PartialFunction[Throwable, T], f : => T)
Wraps a "try" block around the function f [details]
If f throws an exception with its class in the 'ignore' list or if 'ignore' is null or an empty list, ignore the exception and return None.
param
f - - the block of code to evaluate
handler - - A partial function that handles exceptions
return
-
  • Full(result of the evaluation of f) if f doesn't throw any exception
  • a Failure if f throws an exception
Box[T] ControlHelpers
tryo.. def tryo[T](f : => T)
Wraps a "try" block around the function f [details]
param
f - - the block of code to evaluate
return
-
  • Full(result of the evaluation of f) if f doesn't throw any exception
  • a Failure if f throws an exception
Box[T] ControlHelpers
tryo.. def tryo[T](ignore : List[Class[Any]])(f : => T)
Wraps a "try" block around the function f [details]
param
f - - the block of code to evaluate
ignore - - a list of exception classes to ignore. A thrown exception will be ignored if it is assignable from one of the exception classes in the list
return
-
  • Full(result of the evaluation of f) if f doesn't throw any exception
  • a Failure if f throws an exception
  • Empty if the exception class is in the ignore list
Box[T] ControlHelpers
tryo.. def tryo[T](ignore : List[Class[Any]], onError : Box[(Throwable) => Unit])(f : => T)
Wraps a "try" block around the function f [details]
If f throws an exception with its class in the 'ignore' list or if 'ignore' is null or an empty list, ignore the exception and return None.
param
onError - - an optional callback function that will use the thrown exception as a parameter
f - - the block of code to evaluate
ignore - - a list of exception classes to ignore. A thrown exception will be ignored if it is assignable from one of the exception classes in the list
return
-
  • Full(result of the evaluation of f) if f doesn't throw any exception
  • a Failure if f throws an exception
  • Empty if the exception class is in the ignore list
Box[T] ControlHelpers
unCamelCase.. def unCamelCase(name : String) String ClassHelpers
wait.. final def wait(arg0 : Long) Unit AnyRef
wait.. final def wait Unit AnyRef
wait.. final def wait(arg0 : Long, arg1 : Int) Unit AnyRef
weeks.. def weeks(in : Long)
[details]
return
- the number of millis corresponding to 'in' weeks
Long TimeHelpers
year.. def year(in : Date)
[details]
return
- the year corresponding to today (relative to UTC)
Int TimeHelpers
Copyright (c) 2006-2010 WorldWide Conferencing, LLC. All Rights Reserved.