use of java.text.DateFormat in project neo4j by neo4j.
the class TransactionThroughputChecker method newDateFormat.
private static DateFormat newDateFormat() {
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
TimeZone timeZone = TimeZone.getTimeZone("UTC");
format.setTimeZone(timeZone);
return format;
}
use of java.text.DateFormat in project zipkin by openzipkin.
the class UtilTest method midnightUTCTest.
@Test
public void midnightUTCTest() throws ParseException {
DateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX");
iso8601.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date = iso8601.parse("2011-04-15T20:08:18Z");
long midnight = midnightUTC(date.getTime());
assertThat(iso8601.format(new Date(midnight))).isEqualTo("2011-04-15T00:00:00Z");
}
use of java.text.DateFormat in project sensorreadout by onyxbits.
the class TimeChart method getDateFormat.
/**
* Returns the date format pattern to be used, based on the date range.
*
* @param start the start date in milliseconds
* @param end the end date in milliseconds
* @return the date format
*/
private DateFormat getDateFormat(double start, double end) {
if (mDateFormat != null) {
SimpleDateFormat format = null;
try {
format = new SimpleDateFormat(mDateFormat);
return format;
} catch (Exception e) {
// do nothing here
}
}
DateFormat format = SimpleDateFormat.getDateInstance(SimpleDateFormat.MEDIUM);
double diff = end - start;
if (diff > DAY && diff < 5 * DAY) {
format = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.SHORT);
} else if (diff < DAY) {
format = SimpleDateFormat.getTimeInstance(SimpleDateFormat.MEDIUM);
}
return format;
}
use of java.text.DateFormat in project openhab1-addons by openhab.
the class EBusTelegramCSVWriter method writeTelegram.
/**
* Writes a eBUS telegram to the CSV file
*
* @param telegram
* @param comment
* @throws IOException
*/
public synchronized void writeTelegram(EBusTelegram telegram, String comment) {
try {
if (writer == null) {
return;
}
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
writer.write(df.format(date));
writer.write(";");
writer.write('"' + EBusUtils.toHexDumpString(telegram.getType()) + '"');
writer.write(";");
writer.write('"' + EBusUtils.toHexDumpString(telegram.getSource()) + '"');
writer.write(";");
writer.write('"' + EBusUtils.toHexDumpString(telegram.getDestination()) + '"');
writer.write(";");
short u = telegram.getCommand();
byte x = (byte) u;
byte y = (byte) (u >> 8);
writer.write(EBusUtils.toHexDumpString(y));
writer.write(" ");
writer.write(EBusUtils.toHexDumpString(x));
writer.write(";");
writer.write('"' + EBusUtils.toHexDumpString((byte) telegram.getDataLen()) + '"');
writer.write(";");
writer.write(EBusUtils.toHexDumpString(telegram.getData()).toString());
writer.write(";");
writer.write('"' + EBusUtils.toHexDumpString(telegram.getCRC()) + '"');
writer.write(";");
if (telegram.getType() != EBusTelegram.TYPE_MASTER_SLAVE) {
writer.write(";");
writer.write(";");
writer.write(";");
writer.write(";");
} else {
writer.write('"' + "00" + '"');
writer.write(";");
writer.write('"' + EBusUtils.toHexDumpString((byte) telegram.getSlaveDataLen()) + '"');
writer.write(";");
writer.write(EBusUtils.toHexDumpString(telegram.getSlaveData()).toString());
writer.write(";");
writer.write('"' + EBusUtils.toHexDumpString((byte) telegram.getSlaveCRC()) + '"');
writer.write(";");
}
writer.write(comment);
writer.newLine();
writer.flush();
} catch (IOException e) {
logger.error("error", e);
}
}
use of java.text.DateFormat in project jodd by oblac.
the class CalendarConverterTest method testCalendarDate.
@Test
public void testCalendarDate() {
JDateTime jdt = new JDateTime();
CalendarConverter calendarConverter = new CalendarConverter();
Calendar gc = calendarConverter.convert(jdt);
DateFormat df = new SimpleDateFormat();
assertEquals(df.format(gc.getTime()), df.format(Convert.toDate(jdt)));
}
Aggregations