Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

String to date and calculate the end of period

Posted on 2002-06-18
2
Medium Priority
?
209 Views
Last Modified: 2010-04-01
Hello!
Well, I get back a date of the beginning of period
and I should calculate the date of the end of period.

First problem, the date of the beginning is a string. So, it is necessary to convert to Date object.
Second problem, I should calculate the date of the end.
Ex: date at the beginning of 2002-02-01 then the date of the end will be 2003-01-31).

But I don't know how to make!
Thank you for his help!
Ankou
0
Comment
Question by:ldanet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 92

Accepted Solution

by:
objects earned 400 total points
ID: 7086611
Try something like:

SimpleDataFormat df = new SimpleDateFormat("yyyy-MM-dd");
Date d = df.parse(input);
Calendar c = Calendar.getInstance();
c.setTime(d);
c.add(field, period);
String output = df.format(c.getTime());
0
 
LVL 92

Expert Comment

by:objects
ID: 7086755
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An overview of cyber security, cyber crime, and personal protection against hackers. Includes a brief summary of the Equifax breach and why everyone should be aware of it. Other subjects include: how cyber security has failed to advance with technol…
If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question