Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

conversion of  timestamp

Posted on 2013-11-27
2
Medium Priority
?
260 Views
Last Modified: 2013-12-01
Hello

let me know how to convert this date as string  datatype to timestamp on report.java file

here is the  
public class Report {

	//SimpleDateFormat formatter = new SimpleDateFormat("MM-dd-yyyy"); 
	
	private String date;
	
	
	public String getDate() {
	
	return date;
	}

	public void setDate(String date) {
		this.date = date;
	}
	
	private String Impressions;
	private String Clicks;
	private String Earning;
	
	
	public String getImpressions() {
		return Impressions;
	}
	public void setImpressions(String impressions) {
		Impressions = impressions;
	}
	public String getClicks() {
		return Clicks;
	}
	public void setClicks(String clicks) {
		Clicks = clicks;
	}
	public String getEarning() {
		return Earning;
	}
	public void setEarning(String earning) {
		Earning = earning;
	}

	
}

Open in new window


Thanks
0
Comment
Question by:roy_sanu
2 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 39680562
Well MM-dd-yyyy doesn't have any time information ...
0
 
LVL 21

Accepted Solution

by:
Amitkumar Panchal earned 2000 total points
ID: 39682678
Assuming date format is MM-dd-yyyy (for eg. 11-28-2013)

You can add following in your code

SimpleDateFormat formatter = new SimpleDateFormat("MM-dd-yyyy");

public Date getCovertedDate() {
      try {
          formatter.parse(this.date);
      } catch (Exception ex) {
         ex.printStackTrace();
      }
      return null;
}


Make sure to freeze the date format as you will need to specify it with SimteDateFormat.

Refer http://www.xyzws.com/Javafaq/how-to-use-simpledateformat-class-formating-parsing-date-and-time/142 for more details about formatting characters and example
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

877 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