Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to format text from 01/12/1999 to 01121999 ?  RSS feed

 
Steve Wutang
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a jlabel which shows
01/12/1999 (date).
i want to put this in a string that stores
the value 01121999.
how do i strip off the / from the
jlabel.getText() ?
Thanks
 
Doug Gschwind
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first thing to look into is the java.text.DateFormat class. That may be all you need.
You can also use a GregorianCalendar instance (from java.util package I believe) with a specific date in time (e.g. new Date()) and then work with the atomic pieces of information such as day of month, month, year, hour of day, etc.
 
Doug Gschwind
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops!
I was answering a different question. You can use the indexOf() operation on String to find the location of a given '/' character, then just concatenate substrings of the original string that leave the '/' characters behind.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or use my favourite StringTokenizer:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!