1 package org.apache.maven.project.interpolation;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.text.SimpleDateFormat;
23 import java.util.Date;
24
25 import org.codehaus.plexus.interpolation.AbstractValueSource;
26
27
28
29
30
31 public class BuildTimestampValueSource
32 extends AbstractValueSource
33 {
34
35 private final Date startTime;
36
37 private final String format;
38
39 private String formattedDate;
40
41 public BuildTimestampValueSource( Date startTime, String format )
42 {
43 super( false );
44 this.startTime = startTime;
45 this.format = format;
46 }
47
48 public Object getValue( String expression )
49 {
50 if ( "build.timestamp".equals( expression ) || "maven.build.timestamp".equals( expression ) )
51 {
52 if ( formattedDate == null && startTime != null )
53 {
54 formattedDate = new SimpleDateFormat( format ).format( startTime );
55 }
56
57 return formattedDate;
58 }
59
60 return null;
61 }
62
63 }