• 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
  • currenttime

    Prev Next
    Macro
    Get the current system time as milliseconds since epoch

    Summary

    The currenttime macro returns the current system time as a long integer representing milliseconds since the Unix epoch (January 1, 1970, 00:00:00 UTC). This provides a precise timestamp for build-time operations.

    Syntax

    ${currenttime}
    

    Parameters

    None - this macro takes no parameters.

    Behavior

    • Returns the current system time in milliseconds
    • Uses System.currentTimeMillis() internally
    • The value represents milliseconds since January 1, 1970, 00:00:00 UTC
    • The timestamp is captured at the time the macro is evaluated

    Examples

    Capture build time:

    Build-Time: ${currenttime}
    

    Use as a unique identifier component:

    Build-Id: ${bsn}-${currenttime}
    

    Create timestamped filenames:

    output.file=bundle-${currenttime}.jar
    

    Calculate elapsed time (with another timestamp):

    # In combination with other macros for time calculations
    

    Use Cases

    • Recording precise build timestamps
    • Creating unique build identifiers
    • Timestamping artifacts
    • Calculating build durations
    • Versioning based on build time
    • Creating time-based unique values

    Notes

    • The value is in milliseconds, not seconds
    • To convert to a readable date format, use the ${long2date} macro
    • The timestamp represents UTC time
    • For formatted timestamps, use ${tstamp} macro instead
    • This is different from ${now} which returns seconds since epoch

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home