Reputation: 1950
how to get current date in DD-MM-YYYY
format in BlackBerry
i have already tried the following, but it gives me output of 1318502493
long currentTime = System.currentTimeMillis() / 1000;
System.out.println("Current time in :" + currentTime);
Upvotes: 12
Views: 50873
Reputation: 2244
private String pattern = "dd-MM-yyyy";
String dateInString =new SimpleDateFormat(pattern).format(new Date());
Upvotes: 26
Reputation: 1902
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
return formatter.format(new Date());
Upvotes: 8
Reputation: 591
Check if you can use SimpleDateFormat. If you can, create an object of this class, and use it in order to format the return provided by System.currentTimeMillis(). Some code below:
import java.util.*;
import java.text.*;
public class DateTest {
public static String getCurrentTimeStamp() {
SimpleDateFormat formDate = new SimpleDateFormat("dd-MM-yyyy");
// String strDate = formDate.format(System.currentTimeMillis()); // option 1
String strDate = formDate.format(new Date()); // option 2
return strDate;
}
public static void main (String args[]) {
System.out.println(getCurrentTimeStamp());
}
}
Upvotes: 3