logo
  • 教程列表
  • SO官方文檔
  • 格式化字串
    • 格式化字串資源
    • 將資料型別格式化為 String,反之亦然
    • 將時間戳格式化為字串
  1. StackOverflow 文件
  2. Android 教程
  3. 格式化字串
  4. 將時間戳格式化為字串

將時間戳格式化為字串

Created: November-22, 2018

有關模式的完整說明,請參閱 SimpleDateFormat 參考

Date now = new Date();
long timestamp = now.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy", Locale.US);
String dateStr = sdf.format(timestamp);
  • 將資料型別格式化為 String,反之亦然

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明