获取时间在德国 - 机器人机器人、时间、在德国

2023-09-08 09:09:55 作者:劫后余生

我怎样才能得到当前的时间在德国无论用户和当前设备的时间位置?

 日历buttoncal = Calendar.getInstance();
    串tdate =新的SimpleDateFormat(dd.MM,Locale.GERMANY).format(buttoncal.getTime());
    串tday =新的SimpleDateFormat(EEEE,Locale.GERMANY).format(buttoncal.getTime());


    one_date.setText(tdate.toString());
    one_day.setText(tday);
 

解决方案

使用的 android.text.format.Time ,而不是作为我建议在这里。

MTBF 突破8万小时 珞石机器人获国家级评测中心认证

How can I get the current time in Germany regardless of the location of the user and current device time?

    Calendar buttoncal = Calendar.getInstance();
    String tdate = new SimpleDateFormat("dd.MM",Locale.GERMANY).format(buttoncal.getTime());
    String tday  = new SimpleDateFormat("EEEE",Locale.GERMANY).format(buttoncal.getTime());


    one_date.setText(tdate.toString());
    one_day.setText(tday);

解决方案

Use android.text.format.Time instead as I suggested over here.