• Intro Headers Instructions Macros Commands
Fork me on GitHub
    • Getting Started
      • Introduction
      • How to install bnd
      • Guided Tour Workspace & Projects
      • bnd / bndlib Features and JAR Wrapping Techniques
      • FAQ - Frequently Asked Questions
    • Concepts and Practices
      • Concepts
      • Background
      • Best practices
    • Build and Development
      • Build
      • Generating JARs
      • Versioning
      • Baselining
      • Service Components
      • Metatype
      • Contracts
      • Bundle Annotations
      • Accessor Properties
      • SPI Annotations
    • Dependency and Launching
      • Resolving Dependencies
      • Launching
      • Startlevels
    • Testing
      • Testing
      • Testing with Launchpad
    • Packaging and Distribution
      • Packaging Applications
      • JPMS Libraries
      • Wrapping Libraries to OSGi Bundles
    • Documentation and Tools
      • Generating Documentation
      • bnd CLI Commands
      • For Developers
      • Templates for Workspaces
      • Tips for Windows users
      • Tools bound to bnd
    • Reference Material
      • Reference
      • Headers
      • Instruction Reference
      • Instruction Index
      • Macro Reference
      • Macro Index
      • Plugins
      • External Plugins
    • Configuration and Troubleshooting
      • Settings
      • Errors
      • Warnings
  • long2date

    Prev Next
    Macro
    Convert a millisecond timestamp to a readable date string

    Summary

    The long2date macro converts a long integer representing milliseconds since the Unix epoch (January 1, 1970, 00:00:00 UTC) into a human-readable date string.

    Syntax

    ${long2date;<milliseconds>}
    

    Parameters

    • milliseconds - A long integer representing milliseconds since epoch

    Behavior

    • Parses the input as a long integer
    • Converts to a formatted date string
    • Returns “not a valid long” if parsing fails
    • Uses a standard date format for output

    Examples

    Convert current time:

    ${long2date;${currenttime}}
    # Returns: "Wed Nov 20 10:30:45 UTC 2024" (example)
    

    Convert stored timestamp:

    Build-Date: ${long2date;1700000000000}
    # Returns human-readable date
    

    Format file modification time:

    Modified: ${long2date;${fmodified;${@}}}
    

    Display build timestamp:

    ${long2date;${tstamp}}
    

    Use Cases

    • Converting timestamps to readable dates
    • Displaying build times in manifests
    • Formatting file modification times
    • Debugging timestamp values
    • Creating human-readable logs
    • Documentation generation with dates

    Notes

    • Input must be milliseconds (not seconds)
    • Returns “not a valid long” for invalid input
    • Date format is standard Java Date.toString() format
    • The output format is not customizable in this macro
    • For custom date formatting, use ${tstamp} macro
    • See also: ${currenttime} for getting current time in milliseconds
    • See also: ${tstamp} for formatted timestamps
    • See also: ${now} for seconds since epoch

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home