You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by dl...@apache.org on 2002/03/27 19:51:06 UTC
cvs commit: jakarta-velocity/src/java/org/apache/velocity/app/tools VelocityFormatter.java
dlr 02/03/27 10:51:06
Modified: src/java/org/apache/velocity/app/tools
VelocityFormatter.java
Log:
o Cleaned up date formatting methods.
o Changed formatVector() methods to take List instead of Vector, and
optimized implementation of 3 param version.
Revision Changes Path
1.8 +27 -28 jakarta-velocity/src/java/org/apache/velocity/app/tools/VelocityFormatter.java
Index: VelocityFormatter.java
===================================================================
RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/app/tools/VelocityFormatter.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -u -r1.7 -r1.8
--- VelocityFormatter.java 16 Oct 2001 23:14:29 -0000 1.7
+++ VelocityFormatter.java 27 Mar 2002 18:51:06 -0000 1.8
@@ -80,7 +80,7 @@
*
* @author <a href="sean@somacity.com">Sean Legassick</a>
* @author <a href="dlr@collab.net">Daniel Rall</a>
- * @version $Id: VelocityFormatter.java,v 1.7 2001/10/16 23:14:29 dlr Exp $
+ * @version $Id: VelocityFormatter.java,v 1.8 2002/03/27 18:51:06 dlr Exp $
*/
public class VelocityFormatter
{
@@ -98,34 +98,32 @@
}
/**
- * Formats a date in 'short' style.
+ * Formats a date in <code>DateFormat.SHORT</code> style.
*
- * @param date A Date.
- * @return A String.
+ * @param date The date to format.
+ * @return The formatted date as text.
*/
public String formatShortDate(Date date)
{
- return DateFormat
- .getDateInstance(DateFormat.SHORT).format(date);
+ return DateFormat.getDateInstance(DateFormat.SHORT).format(date);
}
/**
- * Formats a date in 'long' style.
+ * Formats a date in <code>DateFormat.LONG</code> style.
*
- * @param date A Date.
- * @return A String.
+ * @param date The date to format.
+ * @return The formatted date as text.
*/
public String formatLongDate(Date date)
{
- return DateFormat
- .getDateInstance(DateFormat.LONG).format(date);
+ return DateFormat.getDateInstance(DateFormat.LONG).format(date);
}
/**
* Formats a date/time in 'short' style.
*
- * @param date A Date.
- * @return A String.
+ * @param date The date to format.
+ * @return The formatted date as text.
*/
public String formatShortDateTime(Date date)
{
@@ -137,8 +135,8 @@
/**
* Formats a date/time in 'long' style.
*
- * @param date A Date.
- * @return A String.
+ * @param date The date to format.
+ * @return The formatted date as text.
*/
public String formatLongDateTime(Date date)
{
@@ -207,49 +205,50 @@
/**
* Formats a vector into the form "A, B and C".
*
- * @param vector A Vector.
+ * @param list The list of elements to format.
* @return A String.
*/
- public String formatVector(Vector vector)
+ public String formatVector(List list)
{
- return formatVector(vector, ", ", " and ");
+ return formatVector(list, ", ", " and ");
}
/**
* Formats a vector into the form "A<delim>B<delim>C".
*
- * @param vector A Vector.
+ * @param list The list of elements to format.
* @param delim A String.
* @return A String.
*/
- public String formatVector(Vector vector,
+ public String formatVector(List list,
String delim)
{
- return formatVector(vector, delim, delim);
+ return formatVector(list, delim, delim);
}
/**
- * Formats a vector into the form
+ * Formats a list into the form
* "Adelim>B<finaldelim>C".
*
- * @param vector A Vector.
+ * @param list The list of elements to format.
* @param delim A String.
* @param finalDelim A String.
* @return A String.
*/
- public String formatVector(Vector vector,
+ public String formatVector(List list,
String delim,
String finaldelim)
{
StringBuffer sb = new StringBuffer();
- for (int i = 0; i < vector.size(); i++)
+ int size = list.size();
+ for (int i = 0; i < size; i++)
{
- sb.append(vector.elementAt(i).toString());
- if (i < vector.size() - 2)
+ sb.append(list.get(i));
+ if (i < size - 2)
{
sb.append(delim);
}
- else if (i < vector.size() - 1)
+ else if (i < size - 1)
{
sb.append(finaldelim);
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>