Java Doc for StringUtil.java in  » J2EE » Dinamica » dinamica » 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 » J2EE » Dinamica » dinamica 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   dinamica.StringUtil

StringUtil
public class StringUtil (Code)
Core-level framework class: String and Date basic utility methods.

Encapsulates utility methods for everyday programming tasks with Strings, Dates and other common stuff.
Creation date: 18/09/2003
Last Update: 18/09/2003
(c) 2003 Martin Cordova
This code is released under the LGPL license

author:
   Martin Cordova (some code written by Carlos Pineda)




Method Summary
public static  StringformatDate(java.util.Date d, String format)
    
public static  StringformatDate(java.util.Date d, String format, Locale loc)
    
public static  StringformatNumber(Object value, String numberFormat)
    
public static  StringformatNumber(Object value, String numberFormat, Locale loc)
    
public static  java.util.DategetDateObject(String dateValue, String dateFormat)
    
public static  StringgetResource(javax.servlet.ServletContext ctx, String path)
    
public static  StringgetResource(javax.servlet.ServletContext ctx, String path, String encoding)
    
public static  StringhttpGet(String url, boolean logStdout)
     Retrieve a text-based document using HTTP GET method.
May be used to retrieve XML documents, news feeds, etc.
public static  Stringreplace(String source, String pattern, String newText)
     Replace ALL occurrences of [old value] with [new value]
This method was written by Carlos Pineda.
public static  doubleround(double n, int decimals)
    
public static synchronized  voidsaveMessage(String path, String message)
    
public static  String[]split(String s, String separator)
     Create an array of items from a string with delimiters to separate the items.



Method Detail
formatDate
public static String formatDate(java.util.Date d, String format) throws Throwable(Code)
Format date using a mask and the default locale
Parameters:
  d - Date object
Parameters:
  format - Date mask, like yyyy-MM-dd or any valid java format String representing the formatted string
throws:
  Throwable -



formatDate
public static String formatDate(java.util.Date d, String format, Locale loc) throws Throwable(Code)
Format date using a mask and locale
Parameters:
  d - Date object
Parameters:
  format - Date mask, like yyyy-MM-dd or any valid java format
Parameters:
  loc - Custom Locale String representing the formatted string
throws:
  Throwable -



formatNumber
public static String formatNumber(Object value, String numberFormat) throws Throwable(Code)
Format a number using a valid Java format mask and the default Locale
Parameters:
  value - Double, Integer or another numeric value
Parameters:
  numberFormat - Java numeric format mask like #,##0.00 String representing a formatted number acording to the numberFormat
throws:
  Throwable -



formatNumber
public static String formatNumber(Object value, String numberFormat, Locale loc) throws Throwable(Code)
Format a number using a valid Java format mask and a custom Locale
Parameters:
  value - Double, Integer or another numeric value
Parameters:
  numberFormat - Java numeric format mask like #,##0.00
Parameters:
  loc - Custom Locale to use when formatting the number String representing a formatted number acording to the numberFormat
throws:
  Throwable -



getDateObject
public static java.util.Date getDateObject(String dateValue, String dateFormat) throws Throwable(Code)
Create a java.util.Date object from a String value and a format mask.
The java date formats are supported, for more information please consult the reference guide for the class SimpleDateFormat.

Sample code:
 java.util.Date d = StringUtil.getDateObject("2003-12-07 17:00:00","yyyy-MM-dd HH:mm:ss");
 

Parameters:
  dateValue - A String containg a valid date corresponding to dateFormat mask
Parameters:
  dateFormat - The date format used to represent the date in dateValue A java.util.Date object representing the dateValue parameter
throws:
  Throwable - if dateValue is not represented in dateFormat



getResource
public static String getResource(javax.servlet.ServletContext ctx, String path) throws Throwable(Code)
Loads a text resource stored into the Web Application context paths
Parameters:
  path - Path to the resource String containing the resource contents
throws:
  Exception -



getResource
public static String getResource(javax.servlet.ServletContext ctx, String path, String encoding) throws Throwable(Code)
Loads a text resource stored into the Web Application context paths
PATCH 2005-02-17 (v2.0.3) - encoding support
Parameters:
  ctx - Servlet context
Parameters:
  path - Path to the resource
Parameters:
  encoding - Canonical name of the encoding to be used to read the resource String containing the resource contents
throws:
  Exception -



httpGet
public static String httpGet(String url, boolean logStdout) throws Throwable(Code)
Retrieve a text-based document using HTTP GET method.
May be used to retrieve XML documents, news feeds, etc.
Parameters:
  url - A valid URL
Parameters:
  logStdout - if TRUE then this method will printa tracelog via STDOUT a String containing the whole document
throws:
  Throwable -



replace
public static String replace(String source, String pattern, String newText)(Code)
Replace ALL occurrences of [old value] with [new value]
This method was written by Carlos Pineda.
Parameters:
  source - String to manipulate
Parameters:
  pattern - Old value
Parameters:
  newText - New value String with replaced text



round
public static double round(double n, int decimals) throws Throwable(Code)
Rounds a double to a given number of decimals.
Example: double x = StringUtil.round(100.0500023, 4);
yields: x = 100.0500
Parameters:
  n - Number
Parameters:
  decimals - Number of decimals to use in the trim operation A double with trimmed decimals.
throws:
  Throwable -



saveMessage
public static synchronized void saveMessage(String path, String message)(Code)
Append message to file, this method is usually used to save log messages
Parameters:
  path - File name
Parameters:
  message - String to append to file



split
public static String[] split(String s, String separator)(Code)
Create an array of items from a string with delimiters to separate the items. This is a very simple wrapper around the native String.split method
Parameters:
  s - String to split or separate in its parts
Parameters:
  separator - Delimiter string, like a pipe or a tabulator Array of strings containing the separated items



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.