List of usage examples for java.text DateFormat setTimeZone
public void setTimeZone(TimeZone zone)
From source file:MyServlet.java
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/plain"); PrintWriter out = res.getWriter(); res.setHeader("Content-Language", "es"); Locale locale = new Locale("es", ""); DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); fmt.setTimeZone(TimeZone.getDefault()); out.println("En Espa\u00f1ol:"); out.println("\u00a1Hola Mundo!"); out.println(fmt.format(new Date())); }
From source file:com.amazonaws.devicefarm.android.referenceapp.Fragments.Tabs.Inputs.Input_RefreshButtonFragment.java
/** * Called when refreshing//from w w w. j av a 2 s . c o m */ @Override public void onRefresh() { Calendar cal = Calendar.getInstance(TimeZone.getDefault()); Date currentLocalTime = cal.getTime(); DateFormat date = new SimpleDateFormat("hh:mm:ss a"); date.setTimeZone(TimeZone.getDefault()); textView.setText(date.format(currentLocalTime)); swipeRefreshLayout.setRefreshing(false); }
From source file:org.jersey2.simple.jersey.ObjectMapperProvider.java
public ObjectMapperProvider() { this.objectMapper = new ObjectMapper(); this.objectMapper.enable(SerializationFeature.INDENT_OUTPUT); //set up ISO 8601 date/time stamp format: final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:sss'Z'"); df.setTimeZone(TimeZone.getTimeZone("UTC")); this.objectMapper.setDateFormat(df); }
From source file:edu.kit.dama.mdm.audit.impl.ConsoleConsumer.java
@Override public void consume(AuditEvent entry) { StringBuilder b = new StringBuilder(); final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); df.setTimeZone(TimeZone.getTimeZone("UTC")); b.append(entry.getPid()).append("|").append(entry.getEventType()).append("|").append(entry.getCategory()) .append("|").append(df.format(entry.getEventDate())).append("|").append(entry.getOwner()) .append("|").append(entry.getAgent()).append("|").append(entry.getResource()).append("|") .append(entry.getDetails()); System.out.println(b.toString()); }
From source file:org.bml.util.time.DateFormatFactory.java
@Override public DateFormat makeObject() { DateFormat df = new SimpleDateFormat(stringFormat); df.setTimeZone(defaultTimeZone); return df;/*ww w. ja va2s . c om*/ }
From source file:org.openmrs.module.emrapi.encounter.DateMapper.java
public Date convertUTCToDate(String date) { if (!StringUtils.isBlank(date)) { try {//from w w w .java 2 s . c om DateFormat utcFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); utcFormat.setTimeZone(TimeZone.getTimeZone("UTC")); return utcFormat.parse(date); } catch (ParseException e) { throw new RuntimeException("Date format needs to be in UTC format. Incorrect Date:" + date + ".", e); } } return null; }
From source file:edu.kit.dama.mdm.audit.impl.LogbackPublisher.java
@Override public void publish(AuditEvent entry) { StringBuilder b = new StringBuilder(); final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); df.setTimeZone(TimeZone.getTimeZone("UTC")); b.append(entry.getPid()).append("|").append(entry.getEventType()).append("|").append(entry.getCategory()) .append("|").append(df.format(entry.getEventDate())).append("|").append(entry.getOwner()) .append("|").append(entry.getAgent()).append("|").append(entry.getResource()).append("|") .append(entry.getDetails()); LOGGER.info(b.toString());/*ww w . jav a 2 s .c o m*/ }
From source file:org.apache.falcon.resource.EntityManagerJerseyIT.java
static List<Path> createTestData() throws Exception { List<Path> list = new ArrayList<Path>(); fs.mkdirs(new Path("/user/guest")); fs.setOwner(new Path("/user/guest"), TestContext.REMOTE_USER, "users"); DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd/HH/mm"); formatter.setTimeZone(TimeZone.getTimeZone("UTC")); Date date = new Date(System.currentTimeMillis() + 3 * 3600000); Path path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); fs.create(path).close();//from w w w . j a v a 2 s . c om date = new Date(date.getTime() - 3600000); path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); fs.create(path).close(); date = new Date(date.getTime() - 3600000); path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); fs.create(path).close(); date = new Date(date.getTime() - 3600000); path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); list.add(path); fs.create(path).close(); date = new Date(date.getTime() - 3600000); path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); list.add(path); fs.create(path).close(); date = new Date(date.getTime() - 3600000); path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); list.add(path); fs.create(path).close(); date = new Date(date.getTime() - 3600000); path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); list.add(path); fs.create(path).close(); date = new Date(date.getTime() - 3600000); path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); list.add(path); fs.create(path).close(); date = new Date(date.getTime() - 3600000); path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); list.add(path); fs.create(path).close(); date = new Date(date.getTime() - 3600000); path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); list.add(path); fs.create(path).close(); new FsShell(new Configuration()) .run(new String[] { "-chown", "-R", "guest:users", "/examples/input-data/rawLogs", }); return list; }
From source file:org.apache.falcon.resource.EntityManagerJerseyIT.java
static List<Path> createTestData(TestContext context) throws Exception { List<Path> list = new ArrayList<Path>(); FileSystem fs = context.cluster.getFileSystem(); fs.mkdirs(new Path("/user/guest")); fs.setOwner(new Path("/user/guest"), TestContext.REMOTE_USER, "users"); DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd/HH/mm"); formatter.setTimeZone(TimeZone.getTimeZone("UTC")); Date date = new Date(System.currentTimeMillis() + 3 * 3600000); Path path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); fs.create(path).close();/*from w w w. j a va 2 s . c o m*/ date = new Date(date.getTime() - 3600000); path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); fs.create(path).close(); date = new Date(date.getTime() - 3600000); path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); fs.create(path).close(); date = new Date(date.getTime() - 3600000); path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); list.add(path); fs.create(path).close(); date = new Date(date.getTime() - 3600000); path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); list.add(path); fs.create(path).close(); date = new Date(date.getTime() - 3600000); path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); list.add(path); fs.create(path).close(); date = new Date(date.getTime() - 3600000); path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); list.add(path); fs.create(path).close(); date = new Date(date.getTime() - 3600000); path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); list.add(path); fs.create(path).close(); date = new Date(date.getTime() - 3600000); path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); list.add(path); fs.create(path).close(); date = new Date(date.getTime() - 3600000); path = new Path("/examples/input-data/rawLogs/" + formatter.format(date) + "/file"); list.add(path); fs.create(path).close(); new FsShell(context.cluster.getConf()) .run(new String[] { "-chown", "-R", "guest:users", "/examples/input-data/rawLogs" }); return list; }
From source file:com.orange.clara.pivotaltrackermirror.config.AppConfig.java
@Bean public Jackson2ObjectMapperBuilder objectMapperBuilder() { Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder(); DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); df.setTimeZone(TimeZone.getDefault()); builder.dateFormat(df);/*www . j a v a 2 s . c om*/ return builder; }