Solved

conversion of  timestamp

Posted on 2013-11-27
2
254 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 500 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Python Assistance 7 79
Cipher Configuration on Apache HTTPD 4 62
fibonacci ten numbers 4 38
login form jsp example 2 24
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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

813 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now