source: PerfectFit/Dialog/src/main/java/tudelft/mentalhealth/perfectfit/updatefuncs/Time.java

Last change on this file was 7, checked in by Wouter Pasman, 9 months ago

#124 release PerfectFit sources

File size: 1.0 KB
Line 
1package tudelft.mentalhealth.perfectfit.updatefuncs;
2
3import java.io.IOException;
4import java.util.Arrays;
5import java.util.List;
6
7import com.fasterxml.jackson.annotation.JsonCreator;
8import com.fasterxml.jackson.annotation.JsonProperty;
9
10import tudelft.dialogmanager.parameters.DoubleValue;
11import tudelft.dialogmanager.parameters.Parameters;
12import tudelft.dialogmanager.updatefunctions.UpdateFunction;
13
14/**
15 * Function to get current time in seconds (since 1970).
16 *
17 */
18public class Time implements UpdateFunction {
19 private String timefieldname;
20
21 /**
22 * @param timefieldname the name of the time field to be set.
23 */
24 @JsonCreator
25 public Time(@JsonProperty("timefieldname") String timefieldname)
26 throws IOException {
27 this.timefieldname = timefieldname;
28 }
29
30 @Override
31 public Parameters call(Parameters parameters) {
32 return parameters.with(timefieldname,
33 new DoubleValue(System.currentTimeMillis() / 1000d));
34 }
35
36 @Override
37 public List<String> getAssignedParameters() {
38 return Arrays.asList(timefieldname);
39 }
40
41}
Note: See TracBrowser for help on using the repository browser.