블랙 베리에서 DD-MM-YYYY
형식으로 현재 날짜를 얻는 방법현재 날짜를 dd-mm-yyyy 형식으로 가져옵니다.
이미 다음을 시도했지만 1318502493
long currentTime = System.currentTimeMillis()/1000;
System.out.println("Current time in :" + currentTime);
블랙 베리에서 DD-MM-YYYY
형식으로 현재 날짜를 얻는 방법현재 날짜를 dd-mm-yyyy 형식으로 가져옵니다.
이미 다음을 시도했지만 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());
"DD"는 OP가 정말로 원하는 것이 거의 확실하지 않은 * year *의 날이 될 것입니다. –
좋은 점은, 그가 사용한 패턴을 사용했지만, 당신은 요점을 가지고 :) (편집 됨) –
그냥 시간을 얻고 싶습니다. 어떻게 얻을 수 있습니까? – Swati
SimpleDateFormat을 사용할 수 있는지 확인하십시오. 가능한 경우이 클래스의 객체를 만들고이 객체를 사용하여 System.currentTimeMillis()에서 제공하는 반환 형식을 지정합니다. 아래의 일부 코드는
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());
}
}
개인적으로 나는 'Date'의 매개 변수없는 생성자를 사용합니다. 이는 이미 현재 시간을 가져올 것입니다. 이 방법은 * 더 * 명백합니다. –
및 "금요일 Octomber 14"형식의 응답을 받으려면 어떻게해야합니까? plz 도움이 있다면 – Hitarth
그냥 시간을 갖고 싶습니다. 어떻게받을 수 있습니까? – Swati