Solved

conversion of  timestamp

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
recursion example 16 111
Java Jpanels and Jframe 8 28
fibonacci ten numbers 4 26
java jdbc batch example 8 20
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
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 learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
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…

912 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

23 Experts available now in Live!

Get 1:1 Help Now