cpdf_date_util.dart 816 B

123456789101112131415161718
  1. ///
  2. /// Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
  3. ///
  4. /// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
  5. /// AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
  6. /// UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
  7. /// This notice may not be removed from this file.
  8. class CPDFDateUtil {
  9. static String format(int milliseconds) {
  10. DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(milliseconds);
  11. return '${dateTime.year}-${_format(dateTime.month)}-${_format(dateTime.day)} ${_format(dateTime.hour)}:${_format(dateTime.minute)}:${_format(dateTime.second)}';
  12. }
  13. static String _format(int time) {
  14. return time < 10 ? '0$time' : '$time';
  15. }
  16. }