• Post Reply Bookmark Topic Watch Topic
  • New Topic

parse date format  RSS feed

 
anvi kon
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need help in parsing the date:

I have a date like below:


I want to parse the datarange like below:



thanks
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do this in two steps:

1. Find the '-' in the string and split the string in two on the '-', so that you get two strings containing the begin and end date.
2. Parse the begin and end date strings into Date objects.

You can do the first step with methods in the String class. Lookup the API documentation of the String class and look through it to see what methods you can use.

For the second step, you can use a SimpleDateFormat.
 
Giovanni Lima
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use StringTokenizer to do it.

 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the API for StringTokenizer:
StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!