8 package cz.vutbr.fit.knot.annotations.modules.suggestionManager.attributes;
12 import java.text.DateFormat;
13 import java.text.SimpleDateFormat;
14 import java.util.TimeZone;
15 import javax.persistence.DiscriminatorValue;
16 import javax.persistence.Entity;
30 @DiscriminatorValue(
"Time")
39 public void setRawValue(String value)
throws IllegalArgumentException {
40 String zone = Util.parseTimeZoneID(value);
41 String originalOffset = TimeZone.getDefault().getID();
43 TimeZone.setDefault(TimeZone.getTimeZone(
"GMT" + zone));
44 this.stringValue = zone;
47 this.dateValue = Util.parseTime(value);
48 }
catch (Exception e) {
50 this.dateValue = Util.parseRFC3339Date(value);
51 }
catch (Exception ex) {
54 DateFormat sdf =
new SimpleDateFormat(
"HH:mm:ss");
55 this.dateValue = sdf.parse(value);
56 }
catch (Exception exx) {
57 throw new IllegalArgumentException(
"Value " + value +
" is not a valid time");
62 TimeZone.setDefault(TimeZone.getTimeZone(originalOffset));
73 if(this.stringValue != null){
74 String originalOffset = TimeZone.getDefault().getID();
75 TimeZone.setDefault(TimeZone.getTimeZone(
"GMT" + this.stringValue));
76 String ret = Util.toRFC3339Time(dateValue);
77 TimeZone.setDefault(TimeZone.getTimeZone(originalOffset));
80 return Util.toRFC3339Time(this.dateValue);
String getTypeOntologyUri()
void setRawValue(String value)
Class representing attribute of type Time for prupose of suggestion.
static final String TIME_URI
Class representing attribute of type DateTime prupose of suggestion.
Utility class (manipulates RFC 3339 dates)