public class StringToTime extends Date
String format, and instantiates a
Date object.
There are two ways to use StringToTime to parse dates:
time(Object), date(Object),
cal(Object))StringToTime with
StringToTime(Object)
The static methods provide a UNIX-style timestamp, a Date
instance, or a Calendar instance. In the event the time
expression provided is invalid, these methods return
Boolean.FALSE.
Instances of StringToTime inherit from Date;
so, when instantiated with an expression that the algorithm recognizes, the
resulting instance of StringToTime can be passed to any method
or caller requiring a Date object. Unlike the static
methods, attempting to create a StringToTime instance with an
invalid expression of time results in a StringToTimeException.
All expressions are case-insensitive.
now (equal to new Date())today (equal to StringToTime("00:00:00.000"))midnight (equal to
StringToTime("00:00:00.000 +24 hours"))morning or this morning (by default, equal to
StringToTime("07:00:00.000"))noon (by default, equal to
StringToTime("12:00:00.000")afternoon or this afternoon (by default, equal
to StringToTime("13:00:00.000")evening or this evening (by default, equal to
StringToTime("17:00:00.000")tonight (by default, equal to
StringToTime("20:00:00.000")tomorrow (by default, equal to
StringToTime("now +24 hours"))tomorrow morning (by default, equal to
StringToTime("morning +24 hours"))noon tomorrow or tomorrow noon (by default,
equal to StringToTime("noon +24 hours"))tomorrow afternoon (by default, equal to
StringToTime("afternoon +24 hours"))yesterday (by default, equal to
StringToTime("now -24 hours"))yesterday and morning,
noon, afternoon, and eveningOctober 26, 1981 or Oct 26, 1981October 26 or Oct 2626 October 198126 Oct 198126 Oct 8110/26/1981 or 10-26-198110/26/81 or 10-26-811981/10/26 or 1981-10-2610/26 or 10-26Copied from github.com/collegeman/stringtotime
| Constructor and Description |
|---|
StringToTime() |
StringToTime(Date date) |
StringToTime(Object dateTimeString) |
StringToTime(Object dateTimeString,
Date now) |
StringToTime(Object dateTimeString,
Date now,
String simpleDateFormat) |
StringToTime(Object dateTimeString,
Integer now) |
StringToTime(Object dateTimeString,
Long now) |
StringToTime(Object dateTimeString,
String simpleDateFormat) |
| Modifier and Type | Method and Description |
|---|---|
static Object |
cal(Object dateTimeString) |
static Object |
cal(Object dateTimeString,
Date now) |
static Object |
date(Object dateTimeString) |
static Object |
date(Object dateTimeString,
Date now) |
String |
format(String simpleDateFormat) |
Calendar |
getCal() |
long |
getTime() |
static Object |
time(Object dateTimeString)
A single parameter version of
time(Object, Date), passing a new
instance of Date as the second parameter. |
static Object |
time(Object dateTimeString,
Date now)
Parse
dateTimeString and produce a timestamp. |
String |
toString() |
after, before, clone, compareTo, equals, from, getDate, getDay, getHours, getMinutes, getMonth, getSeconds, getTimezoneOffset, getYear, hashCode, parse, setDate, setHours, setMinutes, setMonth, setSeconds, setTime, setYear, toGMTString, toInstant, toLocaleString, UTCpublic StringToTime()
public StringToTime(Date date)
public StringToTime(Object dateTimeString)
public long getTime()
getTime in class DateDate.getTime()public Calendar getCal()
Date.getTime()public String format(String simpleDateFormat)
simpleDateFormat - simpleDateFormatSimpleDateFormatpublic String toString()
toString in class DatesimpleDateFormat provided in constructor, then attempts
to format date accordingly; otherwise, returns the
String value of Date.getTime().public static Object time(Object dateTimeString)
time(Object, Date), passing a new
instance of Date as the second parameter.dateTimeString - Long timestamp representative of
dateTimeString, or Boolean
false.time(Object, Date)public static Object time(Object dateTimeString, Date now)
dateTimeString and produce a timestamp.dateTimeString - now - now.now.
Copyright © 2017 Java Wikipedia API (Bliki engine). All rights reserved.