Solved

conversion of  timestamp

Posted on 2013-11-27
2
257 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
[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 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
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ā€¦
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

710 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