net.m2technologies.open_arm.utilities
Class DateCalendarHelper

java.lang.Object
  extended bynet.m2technologies.open_arm.utilities.DateCalendarHelper

public class DateCalendarHelper
extends java.lang.Object

Copyright 2005 Mark Masterson

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Description:

Version:
0.009
Author:
Mark Masterson

Field Summary
static java.lang.String DEFAULT_FORMAT_PATTERN
          The default formatting pattern to pass to java.text.SimpleDateFormat in order to format a java.util.Calendar as a String
static java.lang.String MILLISEC_TIMESTAMP_FORMAT
          Formatting pattern f�r exact timestamps
 
Method Summary
static java.lang.String getCalendarAsString(java.util.Calendar cal)
          Takes a java.util.Calendar and returns it as a String, formatted with the DEFAULT_FORMAT_PATTERN.
static java.lang.String getCalendarAsString(java.util.Calendar cal, java.lang.String formattingPattern)
          Takes a java.util.Calendar and returns it as a String, formatted with the pattern given as the second parameter to this method.
static java.util.Calendar getCalendarFromString(java.lang.String dateTimeString)
          Takes a String, which should be in the "yyyy-MM-dd HH:mm:ss" format of the DEFAULT_FORMAT_PATTERN constant, and returns a Java Calendar object with the value of the String as the value of the Calendar.
static java.util.Calendar getCalendarFromString(java.lang.String dateTimeString, java.lang.String pattern)
          Takes a String in some format, and a formatting pattern that will be used to parse it, and returns a Calendar with the value of the dateTimeString parameter.
static java.util.Calendar getCalendarFromUnixTime(int unixTime)
          Takes an integer value representing the number of seconds since the Epoch (this is variously referred to as "UNIX time" or "C time") and returns a java.util.Calendar instance for the date it represents.
static java.lang.String getDateAsString(java.util.Date date)
          Takes a java.util.Date and returns it as a String, formatted with the DEFAULT_FORMAT_PATTERN.
static java.lang.String getDateAsString(java.util.Date date, java.lang.String formattingPattern)
          Takes a java.util.Date and returns it as a String, formatted with the pattern given as the second parameter to this method.
static java.util.Date getDateFromString(java.lang.String dateTimeString)
          Takes a String, which should be in the "yyyy-MM-dd HH:mm:ss" format of the DEFAULT_FORMAT_PATTERN constant, and returns a Java Date object with the value of the String as the value of the Date.
static java.util.Date getDateFromString(java.lang.String dateTimeString, java.lang.String pattern)
          Takes a String in some format, and a formatting pattern that will be used to parse it, and returns a Date with the value of the dateTimeString parameter.
static java.lang.String getUnixTimeAsDateString(int unixTime)
          Takes an integer value representing the number of seconds since the Epoch (this is variously referred to as "UNIX time" or "C time") and returns it as a String, formatted according to the DEFAULT_FORMAT_PATTERN, for the java.util.Calendar date it represents.
static int getUnixTimeFromCalendar(java.util.Calendar cal)
          Takes a java.util.Calendar and returns an integer value representing the number of seconds since the Epoch (this is variously referred to as "UNIX time" or "C time").
static java.util.Calendar roundTwoCalendarsToDate(java.util.Calendar calendarToChange, java.util.Calendar referenceCalendar)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FORMAT_PATTERN

public static final java.lang.String DEFAULT_FORMAT_PATTERN
The default formatting pattern to pass to java.text.SimpleDateFormat in order to format a java.util.Calendar as a String

See Also:
Constant Field Values

MILLISEC_TIMESTAMP_FORMAT

public static final java.lang.String MILLISEC_TIMESTAMP_FORMAT
Formatting pattern f�r exact timestamps

See Also:
Constant Field Values
Method Detail

getUnixTimeFromCalendar

public static int getUnixTimeFromCalendar(java.util.Calendar cal)
Takes a java.util.Calendar and returns an integer value representing the number of seconds since the Epoch (this is variously referred to as "UNIX time" or "C time").


getCalendarFromUnixTime

public static java.util.Calendar getCalendarFromUnixTime(int unixTime)
Takes an integer value representing the number of seconds since the Epoch (this is variously referred to as "UNIX time" or "C time") and returns a java.util.Calendar instance for the date it represents.


getUnixTimeAsDateString

public static java.lang.String getUnixTimeAsDateString(int unixTime)
Takes an integer value representing the number of seconds since the Epoch (this is variously referred to as "UNIX time" or "C time") and returns it as a String, formatted according to the DEFAULT_FORMAT_PATTERN, for the java.util.Calendar date it represents.


getCalendarAsString

public static java.lang.String getCalendarAsString(java.util.Calendar cal)
Takes a java.util.Calendar and returns it as a String, formatted with the DEFAULT_FORMAT_PATTERN.


getDateAsString

public static java.lang.String getDateAsString(java.util.Date date)
Takes a java.util.Date and returns it as a String, formatted with the DEFAULT_FORMAT_PATTERN.


getCalendarAsString

public static java.lang.String getCalendarAsString(java.util.Calendar cal,
                                                   java.lang.String formattingPattern)
Takes a java.util.Calendar and returns it as a String, formatted with the pattern given as the second parameter to this method. See java.text.SimpleDateFormat for the allowed pattern Strings.


getDateAsString

public static java.lang.String getDateAsString(java.util.Date date,
                                               java.lang.String formattingPattern)
Takes a java.util.Date and returns it as a String, formatted with the pattern given as the second parameter to this method. See java.text.SimpleDateFormat for the allowed pattern Strings.


getDateFromString

public static java.util.Date getDateFromString(java.lang.String dateTimeString)
Takes a String, which should be in the "yyyy-MM-dd HH:mm:ss" format of the DEFAULT_FORMAT_PATTERN constant, and returns a Java Date object with the value of the String as the value of the Date.

Parameters:
dateTimeString -
Returns:
java.util.Date

getDateFromString

public static java.util.Date getDateFromString(java.lang.String dateTimeString,
                                               java.lang.String pattern)
Takes a String in some format, and a formatting pattern that will be used to parse it, and returns a Date with the value of the dateTimeString parameter.

Parameters:
dateTimeString -
pattern -
Returns:
java.util.Date

getCalendarFromString

public static java.util.Calendar getCalendarFromString(java.lang.String dateTimeString)
Takes a String, which should be in the "yyyy-MM-dd HH:mm:ss" format of the DEFAULT_FORMAT_PATTERN constant, and returns a Java Calendar object with the value of the String as the value of the Calendar.

Parameters:
dateTimeString - Value that should be converted to a Calendar.
Returns:
Calendar

getCalendarFromString

public static java.util.Calendar getCalendarFromString(java.lang.String dateTimeString,
                                                       java.lang.String pattern)
Takes a String in some format, and a formatting pattern that will be used to parse it, and returns a Calendar with the value of the dateTimeString parameter.

Parameters:
dateTimeString - Value that should be converted to a Calendar.
pattern - java.util.SimpleDateFormat formatting pattern to use to parse the String value.
Returns:
Calendar

roundTwoCalendarsToDate

public static java.util.Calendar roundTwoCalendarsToDate(java.util.Calendar calendarToChange,
                                                         java.util.Calendar referenceCalendar)