Java Doc for DateSupport.java in  » Database-ORM » MMBase » org » mmbase » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database ORM » MMBase » org.mmbase.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.mmbase.util.DateSupport

DateSupport
public class DateSupport (Code)
Some routines to support dates better

The problem that generally occurs is with timezones. Therefore, we have made the following structure:
  • If a date is stored in a database, it is in GMT
  • If a date is displayed, it happens in the timezone of the machine that is calling.
This means that some timezone conversions have to be made. We assume nothing about timezones, we just read the value specified by the system (Timezone.getDefault() call).
author:
   Rico Jansen
author:
   Johannes Verelst
version:
   $Id: DateSupport.java,v 1.29 2008/02/03 17:33:57 nklasens Exp $


Field Summary
static  booleandooffset
     Whether to sue the offset.
static  intoffset
    


Method Summary
public static  DateDate(int year, int week, int day)
    
public static  Stringcolontime(String time)
    
public static  longconvertDateToLong(String date)
    
public static  longcurrentTimeMillis()
    
public static  Stringdate2date(int time)
    
public static  Stringdate2day(int time)
    
public static  Stringdate2string(int time)
    
public static  intdayInYear(Date d)
    
public static  intdaysInMonth(int year, int month)
     Return the number of days in the month in a specified year.
public static  intgetDayInt(int val)
    
public static  longgetMilliOffset()
    
public static  StringgetMonth(int val)
    
public static  StringgetMonthDay(int val)
    
public static  intgetMonthInt(int val)
    
public static  StringgetTime(int val)
    
public static  StringgetTimeSec(int val)
    
public static  StringgetTimeSecLen(int val)
    
public static  intgetWeekDayInt(int val)
    
public static  StringgetYear(int val)
    
public static  voidmain(String args)
    
public static  Stringmakedbmdate(Date da)
    
public static  longmilliDate(int year, int week)
     Return the number milliseconds elapsed from 1-Jan-1970 to the beginning of the given week.
public static  CalendarparseDate(Calendar cal, String date)
    
public static  CalendarparseDateRev(Calendar cal, String date)
    
public static  intparsedate(String sDate)
    
public static  intparsedatetime(String wh)
    
public static  Dateparsedbmdate(String wh)
    
public static  intparsetime(String wh)
    
public static  intsecondInYear(Date d)
    
public static  intweekInYear(Date d)
    

Field Detail
dooffset
static boolean dooffset(Code)
Whether to sue the offset. Set to true when initialization of this class succeeds.



offset
static int offset(Code)
The offset for date conversions for the current zone, in seconds





Method Detail
Date
public static Date Date(int year, int week, int day)(Code)
Return a date, based on a year, a week and the day of that week
For instance: 1999, 40, 4 = The 4th day of the 40th week of 1999
Parameters:
  year - The year
Parameters:
  week - The week
Parameters:
  day - The number of the day in the week A date-object for the given date



colontime
public static String colontime(String time)(Code)
Puts a colon between a time of RFC-1223 format
Parameters:
  time - A string in RFC-1223 format A string with an extra colon



convertDateToLong
public static long convertDateToLong(String date)(Code)
Convert a string (like "12:42:15 1/2/97") to milliseconds from 1970 The timezone used is 'GMT'
Parameters:
  date - String which contains the date and time in the format "hour:minutes:sec day/month/year" the elapsed milliseconds since 1970 from this date



currentTimeMillis
public static long currentTimeMillis()(Code)
Return the current time in milliseconds (for the current-timezone!!) Integer containing the number of milliseconds representing the current time



date2date
public static String date2date(int time)(Code)
Return a string for a given date
Parameters:
  time - Integer representing the time in seconds since 1-Jan-1970 00:00:00 String in the form 'year-month-day hhmmss'
See Also:   DateSupport.date2string
See Also:   DateSupport.date2day



date2day
public static String date2day(int time)(Code)
Return a string for a given date
Parameters:
  time - Integer representing the time in seconds since 1-Jan-1970 00:00:00 String in the form 'year-month-day'
See Also:   DateSupport.date2string
See Also:   DateSupport.date2date



date2string
public static String date2string(int time)(Code)
Return a string for a given date
Parameters:
  time - Integer representing the time in seconds since 1-Jan-1970 00:00:00 String in the form 'hhmmss day/month/year'
See Also:   DateSupport.date2day
See Also:   DateSupport.date2date



dayInYear
public static int dayInYear(Date d)(Code)
Return the number of days that have elapsed from the beginning of the year to the given date
Parameters:
  d - The date The number of days from January 1 to the given date
See Also:   DateSupport.daysInMonth
See Also:   DateSupport.secondInYear
See Also:   DateSupport.weekInYear



daysInMonth
public static int daysInMonth(int year, int month)(Code)
Return the number of days in the month in a specified year. Leap years have to be taken into account
Parameters:
  year - The year valid values 0..100 where 0 is y2k 2000 untill 89 => 2089 and 90 being the year 1990
Parameters:
  month - The month where 0 is januari



getDayInt
public static int getDayInt(int val)(Code)
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the number of the day in the month as an integer
Parameters:
  val - Number of seconds from 1-Jan-1970 00:00:00 Integer containing the number of the day in the month (1 to 31)
See Also:   DateSupport.getTime
See Also:   DateSupport.getTimeSec
See Also:   DateSupport.getTimeSecLen
See Also:   DateSupport.getMonthDay
See Also:   DateSupport.getMonth
See Also:   DateSupport.getYear
See Also:   DateSupport.getMonthInt
See Also:   DateSupport.getWeekDayInt



getMilliOffset
public static long getMilliOffset()(Code)
Return the time-difference between our timezone and GMT Integer containing the number of milliseconds representing the time-difference between us and GMT



getMonth
public static String getMonth(int val)(Code)
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the number of the month
Parameters:
  val - Number of seconds from 1-Jan-1970 00:00:00 String containing the number of the month (1 to 12)
See Also:   DateSupport.getTime
See Also:   DateSupport.getTimeSec
See Also:   DateSupport.getTimeSecLen
See Also:   DateSupport.getMonthDay
See Also:   DateSupport.getYear
See Also:   DateSupport.getMonthInt
See Also:   DateSupport.getWeekDayInt
See Also:   DateSupport.getDayInt



getMonthDay
public static String getMonthDay(int val)(Code)
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the day in the month
Parameters:
  val - Number of seconds from 1-Jan-1970 00:00:00 String containing the day of the month (1 to 31)
See Also:   DateSupport.getTime
See Also:   DateSupport.getTimeSec
See Also:   DateSupport.getTimeSecLen
See Also:   DateSupport.getMonth
See Also:   DateSupport.getYear
See Also:   DateSupport.getMonthInt
See Also:   DateSupport.getWeekDayInt
See Also:   DateSupport.getDayInt



getMonthInt
public static int getMonthInt(int val)(Code)
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the month as an integer
Parameters:
  val - Number of seconds from 1-Jan-1970 00:00:00 Integer containing the value of the month (1 to 12)
See Also:   DateSupport.getTime
See Also:   DateSupport.getTimeSec
See Also:   DateSupport.getTimeSecLen
See Also:   DateSupport.getMonthDay
See Also:   DateSupport.getMonth
See Also:   DateSupport.getYear
See Also:   DateSupport.getWeekDayInt
See Also:   DateSupport.getDayInt



getTime
public static String getTime(int val)(Code)
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the time as a string
Parameters:
  val - Number of seconds from 1-Jan-1970 00:00:00 String in the form 'hhmm' for the given time
See Also:   DateSupport.getTimeSec
See Also:   DateSupport.getTimeSecLen
See Also:   DateSupport.getMonthDay
See Also:   DateSupport.getMonth
See Also:   DateSupport.getYear
See Also:   DateSupport.getMonthInt
See Also:   DateSupport.getWeekDayInt
See Also:   DateSupport.getDayInt



getTimeSec
public static String getTimeSec(int val)(Code)
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the time as a string
Parameters:
  val - Number of seconds from 1-Jan-1970 00:00:00 String in the form 'hhmmss' for the given time
See Also:   DateSupport.getTime
See Also:   DateSupport.getTimeSecLen
See Also:   DateSupport.getMonthDay
See Also:   DateSupport.getMonth
See Also:   DateSupport.getYear
See Also:   DateSupport.getMonthInt
See Also:   DateSupport.getWeekDayInt
See Also:   DateSupport.getDayInt



getTimeSecLen
public static String getTimeSecLen(int val)(Code)
Takes an integer representing the number of seconds from 00:00:00 and returns the time as a string
Parameters:
  val - Number of seconds from 00:00:00 String in the form 'hhmmss' for the given time
See Also:   DateSupport.getTime
See Also:   DateSupport.getTimeSec
See Also:   DateSupport.getMonthDay
See Also:   DateSupport.getMonth
See Also:   DateSupport.getYear
See Also:   DateSupport.getMonthInt
See Also:   DateSupport.getWeekDayInt
See Also:   DateSupport.getDayInt



getWeekDayInt
public static int getWeekDayInt(int val)(Code)
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the number of the day in the week as an integer
Parameters:
  val - Number of seconds from 1-Jan-1970 00:00:00 Integer containing the number of the day in the week (0 to 6)
See Also:   DateSupport.getTime
See Also:   DateSupport.getTimeSec
See Also:   DateSupport.getTimeSecLen
See Also:   DateSupport.getMonthDay
See Also:   DateSupport.getMonth
See Also:   DateSupport.getYear
See Also:   DateSupport.getMonthInt
See Also:   DateSupport.getDayInt



getYear
public static String getYear(int val)(Code)
Takes an integer representing the number of seconds from 1-Jan-1970 00:00:00 and returns the year
Parameters:
  val - Number of seconds from 1-Jan-1970 00:00:00 String containing the year (1900 to ....)
See Also:   DateSupport.getTime
See Also:   DateSupport.getTimeSec
See Also:   DateSupport.getTimeSecLen
See Also:   DateSupport.getMonthDay
See Also:   DateSupport.getMonth
See Also:   DateSupport.getMonthInt
See Also:   DateSupport.getWeekDayInt
See Also:   DateSupport.getDayInt



main
public static void main(String args)(Code)
Main method used for testing purposes
Parameters:
  args - Array of arguments



makedbmdate
public static String makedbmdate(Date da)(Code)
Create date strings in the form yyyy-mm-dd for a given Date object
This format is used in several database (dbm's)
Parameters:
  da - The date input A string in the form yyyy-mm-dd
See Also:   DateSupport.parsedbmdate



milliDate
public static long milliDate(int year, int week)(Code)
Return the number milliseconds elapsed from 1-Jan-1970 to the beginning of the given week.
Parameters:
  year - The year
Parameters:
  week - The number of the week The number of milliseconds between 1-Jan-1970 and the begin of the given week.



parseDate
public static Calendar parseDate(Calendar cal, String date)(Code)
Parse a string containing a date and put it in a calendar
Parameters:
  cal - Calander object that is used for storing the parsed date
Parameters:
  date - String in the form: hour:minute:second day/month/year Calander object representing the parsed date
See Also:   DateSupport
See Also:    parseDateRev



parseDateRev
public static Calendar parseDateRev(Calendar cal, String date)(Code)
Parse a string containing a date and put it in a calendar, the string is in reversed order
Parameters:
  cal - Calander object that is used for storing the parsed date
Parameters:
  date - String in the form: year/month/day hour:minute:second Calander object representing the parsed date
See Also:   DateSupport
See Also:    parseDate



parsedate
public static int parsedate(String sDate)(Code)
Returns the number of seconds from 1-Jan-1970 to a given date
Parameters:
  sDate - String in the form 'yyyyMMdd' Number of seconds from 1-Jan-1970
See Also:   DateSupport.parsetime
See Also:   DateSupport.parsedatetime



parsedatetime
public static int parsedatetime(String wh)(Code)
Returns the number of seconds from 1-Jan-1970 00:00:00 to a given time
Parameters:
  wh - Date in the form 'yyyymmddhhmmss' Number of seconds from 1-Jan-1970 00:00:00 to the given time
See Also:   DateSupport.parsedate
See Also:   DateSupport.parsetime



parsedbmdate
public static Date parsedbmdate(String wh)(Code)
Parse date strings in the form yyyy-mm-dd
This format is used in several database (dbm's)
Parameters:
  wh - The string representing the date in 'yyyy-mm-dd' format A Date object for the given date
See Also:   DateSupport.makedbmdate



parsetime
public static int parsetime(String wh)(Code)
Returns the number of seconds from 00:00:00 to a given time
Parameters:
  wh - Time in the form 'hhmmss' Number of seconds from 00:00:00 to the given time
See Also:   DateSupport.parsedate
See Also:   DateSupport.parsedatetime



secondInYear
public static int secondInYear(Date d)(Code)
Return the number of seconds that have elapsed from the beginning of the year to the given date
Parameters:
  d - The date The number of secods from January 1 to the given date
See Also:   DateSupport.daysInMonth
See Also:   DateSupport.dayInYear
See Also:   DateSupport.weekInYear



weekInYear
public static int weekInYear(Date d)(Code)
Return the number of weeks that have elapsed from the beginning of the year to the given date
Parameters:
  d - The date The number of weeks from January 1 to the given date
See Also:   DateSupport.daysInMonth
See Also:   DateSupport.secondInYear
See Also:   DateSupport.dayInYear



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.