com.jdon.util
类 UtilDateTime

java.lang.Object
  继承者 com.jdon.util.UtilDateTime

public class UtilDateTime
extends Object

Utility class for handling java.util.Date, the java.sql data/time classes and related information

从以下版本开始:
2.0
版本:
$Revision: 1.2 $
作者:
David E. Jones, Andy Zeneski

构造方法摘要
UtilDateTime()
           
 
方法摘要
static String dateToMillis(long now)
          save the datetime of System.currentTimeMillis() to dtatbase persistence.
static String getDateTimeDisp(String datetime)
          datetime is the String of System.currentTimeMillis() 返回标准中国(缺省)的时间显示格式
static Timestamp getDayEnd(Timestamp stamp)
           
static Timestamp getDayEnd(Timestamp stamp, int daysLater)
           
static Timestamp getDayStart(Timestamp stamp)
           
static Timestamp getDayStart(Timestamp stamp, int daysLater)
           
static Timestamp getNextDayStart(Timestamp stamp)
           
static Timestamp monthBegin()
          Makes a Timestamp for the beginning of the month
static Date nowDate()
          Return a Date for right now
static Timestamp nowTimestamp()
          Return a Timestamp for right now
static Date toDate(int month, int day, int year, int hour, int minute, int second)
          Makes a Date from separate ints for month, day, year, hour, minute, and second.
static Date toDate(String dateTime)
          Converts a date and time String into a Date
static Date toDate(String date, String time)
          Converts a date String and a time String into a Date
static Date toDate(String monthStr, String dayStr, String yearStr, String hourStr, String minuteStr, String secondStr)
          Makes a Date from separate Strings for month, day, year, hour, minute, and second.
static String toDateString(Date date)
          Makes a date String in the format MM/DD/YYYY from a Date
static String toDateTimeString(Date date)
          Makes a combined data and time string in the format "MM/DD/YYYY HH:MM:SS" from a Date.
static Date toSqlDate(int month, int day, int year)
          Makes a java.sql.Date from separate ints for month, day, year
static Date toSqlDate(String date)
          Converts a date String into a java.sql.Date
static Date toSqlDate(String monthStr, String dayStr, String yearStr)
          Makes a java.sql.Date from separate Strings for month, day, year
static Time toSqlTime(int hour, int minute, int second)
          Makes a java.sql.Time from separate ints for hour, minute, and second.
static Time toSqlTime(String time)
          Converts a time String into a java.sql.Time
static Time toSqlTime(String hourStr, String minuteStr, String secondStr)
          Makes a java.sql.Time from separate Strings for hour, minute, and second.
static Timestamp toTimestamp(int month, int day, int year, int hour, int minute, int second)
          Makes a Timestamp from separate ints for month, day, year, hour, minute, and second.
static Timestamp toTimestamp(String dateTime)
          Converts a date and time String into a Timestamp
static Timestamp toTimestamp(String date, String time)
          Converts a date String and a time String into a Timestamp
static Timestamp toTimestamp(String monthStr, String dayStr, String yearStr, String hourStr, String minuteStr, String secondStr)
          Makes a Timestamp from separate Strings for month, day, year, hour, minute, and second.
static String toTimeString(Date date)
          Makes a time String in the format HH:MM:SS from a Date.
static String toTimeString(int hour, int minute, int second)
          Makes a time String in the format HH:MM:SS from a separate ints for hour, minute, and second.
static String zeroPadString(String string, int length)
           
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

UtilDateTime

public UtilDateTime()
方法详细信息

nowTimestamp

public static Timestamp nowTimestamp()
Return a Timestamp for right now

返回:
Timestamp for right now

nowDate

public static Date nowDate()
Return a Date for right now

返回:
Date for right now

getDayStart

public static Timestamp getDayStart(Timestamp stamp)

getDayStart

public static Timestamp getDayStart(Timestamp stamp,
                                    int daysLater)

getNextDayStart

public static Timestamp getNextDayStart(Timestamp stamp)

getDayEnd

public static Timestamp getDayEnd(Timestamp stamp)

getDayEnd

public static Timestamp getDayEnd(Timestamp stamp,
                                  int daysLater)

toSqlDate

public static Date toSqlDate(String date)
Converts a date String into a java.sql.Date

参数:
date - The date String: MM/DD/YYYY
返回:
A java.sql.Date made from the date String

toSqlDate

public static Date toSqlDate(String monthStr,
                             String dayStr,
                             String yearStr)
Makes a java.sql.Date from separate Strings for month, day, year

参数:
monthStr - The month String
dayStr - The day String
yearStr - The year String
返回:
A java.sql.Date made from separate Strings for month, day, year

toSqlDate

public static Date toSqlDate(int month,
                             int day,
                             int year)
Makes a java.sql.Date from separate ints for month, day, year

参数:
month - The month int
day - The day int
year - The year int
返回:
A java.sql.Date made from separate ints for month, day, year

toSqlTime

public static Time toSqlTime(String time)
Converts a time String into a java.sql.Time

参数:
time - The time String: either HH:MM or HH:MM:SS
返回:
A java.sql.Time made from the time String

toSqlTime

public static Time toSqlTime(String hourStr,
                             String minuteStr,
                             String secondStr)
Makes a java.sql.Time from separate Strings for hour, minute, and second.

参数:
hourStr - The hour String
minuteStr - The minute String
secondStr - The second String
返回:
A java.sql.Time made from separate Strings for hour, minute, and second.

toSqlTime

public static Time toSqlTime(int hour,
                             int minute,
                             int second)
Makes a java.sql.Time from separate ints for hour, minute, and second.

参数:
hour - The hour int
minute - The minute int
second - The second int
返回:
A java.sql.Time made from separate ints for hour, minute, and second.

toTimestamp

public static Timestamp toTimestamp(String dateTime)
Converts a date and time String into a Timestamp

参数:
dateTime - A combined data and time string in the format "MM/DD/YYYY HH:MM:SS", the seconds are optional
返回:
The corresponding Timestamp

toTimestamp

public static Timestamp toTimestamp(String date,
                                    String time)
Converts a date String and a time String into a Timestamp

参数:
date - The date String: MM/DD/YYYY
time - The time String: either HH:MM or HH:MM:SS
返回:
A Timestamp made from the date and time Strings

toTimestamp

public static Timestamp toTimestamp(String monthStr,
                                    String dayStr,
                                    String yearStr,
                                    String hourStr,
                                    String minuteStr,
                                    String secondStr)
Makes a Timestamp from separate Strings for month, day, year, hour, minute, and second.

参数:
monthStr - The month String
dayStr - The day String
yearStr - The year String
hourStr - The hour String
minuteStr - The minute String
secondStr - The second String
返回:
A Timestamp made from separate Strings for month, day, year, hour, minute, and second.

toTimestamp

public static Timestamp toTimestamp(int month,
                                    int day,
                                    int year,
                                    int hour,
                                    int minute,
                                    int second)
Makes a Timestamp from separate ints for month, day, year, hour, minute, and second.

参数:
month - The month int
day - The day int
year - The year int
hour - The hour int
minute - The minute int
second - The second int
返回:
A Timestamp made from separate ints for month, day, year, hour, minute, and second.

toDate

public static Date toDate(String dateTime)
Converts a date and time String into a Date

参数:
dateTime - A combined data and time string in the format "MM/DD/YYYY HH:MM:SS", the seconds are optional
返回:
The corresponding Date

toDate

public static Date toDate(String date,
                          String time)
Converts a date String and a time String into a Date

参数:
date - The date String: MM/DD/YYYY
time - The time String: either HH:MM or HH:MM:SS
返回:
A Date made from the date and time Strings

toDate

public static Date toDate(String monthStr,
                          String dayStr,
                          String yearStr,
                          String hourStr,
                          String minuteStr,
                          String secondStr)
Makes a Date from separate Strings for month, day, year, hour, minute, and second.

参数:
monthStr - The month String
dayStr - The day String
yearStr - The year String
hourStr - The hour String
minuteStr - The minute String
secondStr - The second String
返回:
A Date made from separate Strings for month, day, year, hour, minute, and second.

toDate

public static Date toDate(int month,
                          int day,
                          int year,
                          int hour,
                          int minute,
                          int second)
Makes a Date from separate ints for month, day, year, hour, minute, and second.

参数:
month - The month int
day - The day int
year - The year int
hour - The hour int
minute - The minute int
second - The second int
返回:
A Date made from separate ints for month, day, year, hour, minute, and second.

toDateString

public static String toDateString(Date date)
Makes a date String in the format MM/DD/YYYY from a Date

参数:
date - The Date
返回:
A date String in the format MM/DD/YYYY

toTimeString

public static String toTimeString(Date date)
Makes a time String in the format HH:MM:SS from a Date. If the seconds are 0, then the output is in HH:MM.

参数:
date - The Date
返回:
A time String in the format HH:MM:SS or HH:MM

toTimeString

public static String toTimeString(int hour,
                                  int minute,
                                  int second)
Makes a time String in the format HH:MM:SS from a separate ints for hour, minute, and second. If the seconds are 0, then the output is in HH:MM.

参数:
hour - The hour int
minute - The minute int
second - The second int
返回:
A time String in the format HH:MM:SS or HH:MM

toDateTimeString

public static String toDateTimeString(Date date)
Makes a combined data and time string in the format "MM/DD/YYYY HH:MM:SS" from a Date. If the seconds are 0 they are left off.

参数:
date - The Date
返回:
A combined data and time string in the format "MM/DD/YYYY HH:MM:SS" where the seconds are left off if they are 0.

monthBegin

public static Timestamp monthBegin()
Makes a Timestamp for the beginning of the month

返回:
A Timestamp of the beginning of the month

zeroPadString

public static final String zeroPadString(String string,
                                         int length)

dateToMillis

public static final String dateToMillis(long now)
save the datetime of System.currentTimeMillis() to dtatbase persistence.

参数:
now -
返回:

getDateTimeDisp

public static String getDateTimeDisp(String datetime)
datetime is the String of System.currentTimeMillis() 返回标准中国(缺省)的时间显示格式



Copyright © 2013. All Rights Reserved.