<commit_before>package brooklyn.web.console.entity

import brooklyn.event.Sensor
import brooklyn.event.SensorEvent
import java.text.DateFormat
import java.text.SimpleDateFormat

/**
 */
public class SensorSummary {
    public final String name
    public final String description
    public final Object value
    public final String timestamp

    private static DateFormat formatter = new SimpleDateFormat("HH:mm:ss dd/MM/yyyy ")

    public SensorSummary(Sensor sensor, Object value) {
        this.name = sensor.name
        this.description = sensor.description
        this.value = value
        this.timestamp = formatter.format(new Date())
    }

    public SensorSummary(SensorEvent event) {
        this.name = event.sensor.name
        this.description = event.sensor.description
        this.value = event.value
        this.timestamp = formatter.format(new Date(event.timestamp))
    }
}<commit_msg>ENGR-1796: changed time to UTC for sensors tab<commit_after>package brooklyn.web.console.entity

import brooklyn.event.Sensor
import brooklyn.event.SensorEvent
import java.text.DateFormat
import java.text.SimpleDateFormat

/**
 */
public class SensorSummary {
    public final String name
    public final String description
    public final Object value
    public final String timestamp

    // formatter is not thread-safe; use thread-local storage
    private static final ThreadLocal<DateFormat> formatter = new ThreadLocal<DateFormat>() {
        @Override protected DateFormat initialValue() {
            SimpleDateFormat result = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
            result.setTimeZone(TimeZone.getTimeZone("GMT"))
            return result
        }
    };

    public SensorSummary(Sensor sensor, Object value) {
        this.name = sensor.name
        this.description = sensor.description
        this.value = value
        this.timestamp = formatter.get().format(new Date())
    }

    public SensorSummary(SensorEvent event) {
        this.name = event.sensor.name
        this.description = event.sensor.description
        this.value = event.value
        this.timestamp = formatter.get().format(new Date(event.timestamp))
    }
}
{'fraction_non_alphanumeric': 0.08356290174471992, 'fraction_numerical': 0.0018365472910927456, 'mean_word_length': 3.0577281191806334, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '378771', 'n_tokens_mistral': 580, 'n_tokens_neox': 574, 'n_words': 150}