xbn.output
Class MFDate

java.lang.Object
  |
  +--xbn.XBNObject
        |
        +--xbn.output.MsgFormat
              |
              +--xbn.output.MFDate

public class MFDate
extends MsgFormat

A MsgFormat that precedes every line of output with a date-time stamp.

Source code:  MFDate.java

Example

Create a date-time stamp with two spaces at the end, and configure it to the Eastern Standard time zone. Then feed the SimpleDateFormat object into this class, for subseqent use in OConfig.
SimpleDateFormat sdf = (new SimpleDateFormat("MM-dd-yyyy HH:mm:ss  "));
sdf.setTimeZone(TimeZone.getTimeZone("EST"));
MFDate MFDate = new MFDate(sdf);
For further information, see Sun's documentation for java.text.SimpleDateFormat and java.text.TimeZone.


Fields inherited from class xbn.XBNObject
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP
 
Constructor Summary
MFDate()
          Create a MFDate with the default SimpleDateFormat.
MFDate(SimpleDateFormat sd_format)
          Create a MFDate.
MFDate(SimpleDateFormat sd_format, String s_indent)
          Create a MFDate.
MFDate(SimpleDateFormat sd_format, String s_indent, boolean b_indentAfterDate)
          Create a MFDate.
 
Method Summary
 String getDateStamp()
          Get the date prefix as a string.
 String getFormatted(boolean b_useIndent, String s_message)
          Get the formatted message.
 SimpleDateFormat getSimpleDateFormat()
          Get the SimpleDateFormat for direct manipulation.
 boolean isIndentAfterDate()
          Will the indent be printed after or before the date stamp?
 void setIndentAfterDate(boolean b_indentAfterDate)
          Declare if the indent should go after the date stamp, or before.
 
Methods inherited from class xbn.output.MsgFormat
getIndent, hasIndent, setIndent, toString
 
Methods inherited from class xbn.XBNObject
getXMsgPrefix, sop, sopl, sopl, throwAX, throwAXIfBadStr, throwAXIfNull, throwAXSpoof
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MFDate

public MFDate()

Create a MFDate with the default SimpleDateFormat.

Equal to MFPlain(new SimpleDateFormat("MM-dd-yyyy HH:mm:ss "))


MFDate

public MFDate(SimpleDateFormat sd_format)

Create a MFDate.

Equal to MFPlain(sd_format, null)


MFDate

public MFDate(SimpleDateFormat sd_format,
              String s_indent)

Create a MFDate.

Equal to MFPlain(sd_format, s_indent, true)


MFDate

public MFDate(SimpleDateFormat sd_format,
              String s_indent,
              boolean b_indentAfterDate)

Create a MFDate.

Parameters:
sd_format - The SimpleDateFormat object. See the documentation at the top of this page for an example. May not be null.
s_indent - Passed directly to MsgFormat constructor.
b_indentAfterDate - Should the indent text be put before or after the date stamp? It looks cooler when after.
Method Detail

getFormatted

public String getFormatted(boolean b_useIndent,
                           String s_message)

Get the formatted message.

Overrides:
getFormatted in class MsgFormat
Returns:
If both b_useIndent and hasIndent equal true and isIndentAfterDate equals...
  • true: Return getDateStamp() + getIndent() + s_message
  • false: Return getIndent() + getDateStamp() + s_message

Otherwise: Return getDateStamp() + s_message

setIndentAfterDate

public final void setIndentAfterDate(boolean b_indentAfterDate)

Declare if the indent should go after the date stamp, or before.

Parameters:
b_indentAfterDate - If true, then the indent text (if hasIndent equals true) will be printed after the date stamp. If false, the indent text will be printed before the date stamp.

isIndentAfterDate

public boolean isIndentAfterDate()

Will the indent be printed after or before the date stamp?

Returns:
true If the indent text (only when hasIndent equals true) will be printed after the date stamp.
false If the indent text will be printed before the date stamp.

getDateStamp

public String getDateStamp()

Get the date prefix as a string.

Returns:
getSimpleDateFormat().format(new Date())


getSimpleDateFormat

public SimpleDateFormat getSimpleDateFormat()

Get the SimpleDateFormat for direct manipulation.




Copyright 1997-2003, Jeff Epstein, All Rights Reserved. See top of source code files for copyright notice.

 

http://sourceforge.net/projects/xbnjava

 

SourceForge.net Logo