I need to get a getTime() method for my chart.. I don't know how get it really. I need something that shows me the date in format for example MMM dd h.m
. Can anyone show me some methods? Thank you
Asked
Active
Viewed 1,382 times
-6

CommonsWare
- 986,068
- 189
- 2,389
- 2,491

David_D
- 1,404
- 4
- 31
- 65
-
1A search on `java date format` turns about 128,000,000 results, including http://www.vogella.com/articles/JavaDateTimeAPI/article.html#formatdata and http://docs.oracle.com/javase/tutorial/i18n/format/dateintro.html and http://java67.blogspot.com/2013/01/how-to-format-date-in-java-simpledateformat-example.html and http://javatechniques.com/blog/dateformat-and-simpledateformat-examples/ – CommonsWare Aug 29 '13 at 12:55
-
[this shows how to get the date](http://stackoverflow.com/questions/5175728/how-to-get-the-current-date-time-in-java)... [this shows how to get a specific format](http://stackoverflow.com/questions/4772425/format-date-in-java)... also, if the "chart" stuff is relevant, you might want to expand on what you mean by that. Are you using any 3rd party libraries etc. – musefan Aug 29 '13 at 12:56
-
yeah i'm using GraphView library.. – David_D Aug 29 '13 at 12:59
-
1@David_D: (as I can't comment on that deleted answer anymore) Firstly, Android is not a language. Secondly, you can actually [write android apps with C#](http://xamarin.com/monoforandroid), so it should be clarified in your question (which it currently is via a java tag) – musefan Aug 29 '13 at 13:00
-
1Okok..sorry and thank you – David_D Aug 29 '13 at 13:01
-
possible duplicate of [How can I get current date in Android?](http://stackoverflow.com/questions/8654990/how-can-i-get-current-date-in-android) – Jibran Khan Aug 29 '13 at 13:01
4 Answers
2
You can use as below :
DateFormat dateFormatter = new SimpleDateFormat("MMM dd hh.mm");
dateFormatter.setLenient(false);
Date today = new Date();
String s = dateFormatter.format(today);

Butani Vijay
- 4,181
- 2
- 29
- 61
0
Try this:
Date cDate = new Date();
String fDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(cDate);

Sanket Shah
- 4,352
- 3
- 21
- 41
0
You can use SimpleDateFormat
for date and time formate. i.e.
Calendar cal = Calendar.getInstance();
cal.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
System.out.println( sdf.format(cal.getTime()) );

Mukesh Kumar Singh
- 4,512
- 2
- 22
- 30
0
Remember that android application development is done in Java.
You can use: Calendar
Calendar c = Calendar.getInstance();
System.out.println(c.getTime());
Output:
Thu Aug 29 13:03:34 GMT 2013
Use the API to get the format you want.

fechidal89
- 723
- 5
- 25