开发者

get current date in dd-mm-yyyy format

how to get current date in DD-MM-YYYY format in BlackBerry

i have already tried the f开发者_如何学Collowing, but it gives me output of 1318502493

long currentTime = System.currentTimeMillis() / 1000;

System.out.println("Current time in :" + currentTime);


private String pattern = "dd-MM-yyyy";
String dateInString =new SimpleDateFormat(pattern).format(new Date());


DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
return formatter.format(new Date());


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());
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜