2010-08-22 8 views

답변

10

java.util.Date 클래스의 메소드는 parse(String s)toString()입니다. 첫 번째 메소드가 더 이상 사용되지 않지만 GWT와 함께 사용하는 메소드입니다. Date 형식의 제어 방법을 원할 경우 String으로 변환 할 때 GWT 특정 클래스 인 com.google.gwt.i18n.client.DateTimeFormat을 사용하십시오. 패턴을 주어진 날짜의 서식을 지정합니다. 이는 Java 자체의 SimpleDateFormat과 유사합니다.

4
import com.google.gwt.i18n.shared.DateTimeFormat; 
import java.util.Date; 

... 

public Date getDate(String dateString) { 
    Date result = null; 
    try { 
     DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat("yyyy-MM-dd"); 
     result = dateTimeFormat.parse(dateString); 
    } catch (Exception e) 
    { 
     // ignore 
    } 
    return result; 
} 
1

것은있는 StringFormat을 날짜를 변환하려면

import com.google.gwt.i18n.shared.DateTimeFormat; 
    import java.util.Date; 

    ... 
    public String getStringFormat(Date inputDate){ 
    String strFormat = null; 
    try{ 
    DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat("DD-MMM-YYYY"); 
    strFormat = dateTimeFormat.format(inputDate); 
    }catch(Exception e){ 
    e.printStackTrace(); 
    } 
    return strFormat; 
    } 
관련 문제